Image page using using up memory
| From: | Tom Peck | Date: | Fri, 04 Aug 2000 04:14:43 +0000 |
| Subject: | Image page using using up memory | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-1539@lists.php.net to get a copy of this message | ||
Hello everyone.
I have a site which has a lot of photos. I recently implemented an option
for people to choose a width and compression that these photos are displayed
in (so people don't complain about the speed etc..).
After a while of this code running - i've been noticing my server (W2k
running IIS) constantly using up all it's memory - and I presume it's
because of the image page i'm using - not releasing it's info. If some
expert could take a look at the code - and recommend any changes - I would
be most appreciated!
Attached below is the code I have written, I hope it is understandable...
Outlook Express does some dumb things to code when it is pasted into a msg!
<?
$d = addslashes($d); //the dir where the picture is
$i1 = addslashes("$d/$i"); //the source of the picture - inc dir
$i2 = substr($i,0,strlen($i)-4); //make a new variable - same as $i but
without the .jpg
$i2 = addslashes("$d/pre/$i2 w $w c $c.jpg"); //pointing to where the new
image would be if it was already created
if(file_exists($i2)){ //if the compression and width has already been saved
then use the existing one
Imagejpeg(imagecreatefromjpeg($i2));
} else { //otherwise create a new image and save it to the 'pre' directory
$size = GetImageSize($i1);
$im_in = imagecreatefromjpeg($i1);
$proportion = $size[0] / $w;
$im_out = ImageCreate($w, $size[1] / $proportion);
ImageCopyResized($im_out, $im_in, 0, 0, 0, 0, $w, $size[1] / $proportion,
$size[0], $size[1]);
Imagejpeg($im_out,$i2,$c);
Imagejpeg($im_out,'',$c);
ImageDestroy($im_in);
ImageDestroy($im_out);
}
?>