Resize image on fly?

Associate
Joined
18 Oct 2002
Posts
2,092
Location
Edinburgh
im trying to resize images on the fly, is it possible?

i got hold of the image resize function which gives a file handle but is it possible to now display this?

PHP:
function resize_jpg($inputFilename, $new_side){	
$imagedata = getimagesize($inputFilename);
	$w = $imagedata[0];	$h = $imagedata[1];
		if ($h > $w) {		$new_w = ($new_side / $h) * $w;
		$new_h = $new_side;		} else {
		$new_h = ($new_side / $w) * $h;		$new_w = $new_side;
	}		$im2 = ImageCreateTrueColor($new_w, $new_h);
	$image = ImageCreateFromJpeg($inputFilename);
	imagecopyResampled ($im2, $image, 0, 0, 0, 0, $new_w, $new_h, $imagedata[0], $imagedata[1]);
	return $im2;}
 
using the original filename would be no help as the function resizes the image and stores it in memory.
im not sure the other function would work either as i need to display it in the middle of a page
 
im basically taking images from a larger photo gallery and using them in posts on my blog script, i don't want the images to be too large and the images change often so i don't really want to save it, there won't be many images on each page, max prob about 6
 
is this not how the likes of gallery 2 work?? gallery 1 used to save the image thumbnails, gallery 2 does it on the fly.
 
well i sorted it now thanks, turns out my glob function wasn't quite right giving a slightly wrong filename
 
Back
Top Bottom