
-----------------------------------
PaddyLong
Thu Jul 24, 2003 11:04 am

a handy dandy image resizing function
-----------------------------------
here's an image resizing function that I wrote for one of my projects... it may be helpful for you too

all it does is make it so the width and height remain in proportion


//this function is used to resize and display images
/*
imagefile - the file name of the image
alt - the tooltip text that appears when you hover over the image
limiter - which value you want to limit - 0 for width, 1 for height
limitervalue - the maximum value that the limiter value can be
isthumbnail - whether or not to make the image into a thumbnail (if yes, then acts as link to itself) - 0 for no, 1 for yes
caption - caption you want to appear under the text ("" for no caption)
align - the div class to use ("" for no div tag)
class - the class you would like the image to be ("" for none)

styles that should be in the page's stylesheet...
imageLink (needed if the isthumbnail parameter is 1) - recomended property - background-color: transparent;
caption (needed if the caption parameter is set)
*/

function resizeimage ($imagefile, $alt, $limiter, $limitervalue, $isthumbnail, $caption, $align, $class){
	$picsize=getimagesize($imagefile);
	if($picsize[$limiter]>$limitervalue){
		$timestoobig=$picsize[$limiter]/$limitervalue;
		$picwidth=floor($picsize[0]/$timestoobig);
		$picheight=floor($picsize[1]/$timestoobig);
	}else{
		$picwidth=$picsize[0];
		$picheight=$picsize[1];
	}
	$outString = "";
	if($align != ""){ $outString .= ""; }
	if($isthumbnail==1){ $outString .= ""; }
	$outString .= "";
	if($caption != ""){ $outString .= "".$caption.""; }
	if($isthumbnail==1){ $outString .= ""; }
	if($align != ""){ $outString .= "\n"; }
	print($outString);
}


edit: made code more universal

-----------------------------------
Amailer
Thu Jul 24, 2003 11:58 am


-----------------------------------
hehe nice,
