By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,528 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,528 IT Pros & Developers. It's quick & easy.


P: 63
okey, I'm not really a PHP programmer, but I'm making an image viewer for my web page. I have a function that makes thumbnails for me

Expand|Select|Wrap|Line Numbers
  2. function addThumb($file)
  3. {
  4.     global $dirPath;
  5.     global $thumbPath;
  7.     $size        = getimagesize($dirPath.$file);        //Image size
  8.     $thumbWidth    = 200;                    //New width.
  9.     $thumbHeight    = ($thumbWidth/$size[0]) * $size[1];    //New height
  11.     $thumb        = imagecreatetruecolor($thumbWidth, $thumbHeight);    //New Image
  12.     $source        = imagecreatefromjpeg($dirPath.$file);            //Open Image
  14.     imagecopyresized($thumb, $source, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $size[0], $size[1]);    //resize $source and save it in $thumb
  15.     imagejpeg($thumb,$thumbPath.$file);    //save $thumb
  16. }
So... do I need imagedestroy()?

I don't really know how PHP allocates or deallocates memory, but I'm thinking that the used memory is deallocated when the function ends. Am I wrong?
Aug 6 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,044
imagedestroy() will free the memory once you say so. Otherwise, the memory will be freed after all of the PHP on that particular page has finished.
Aug 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.