imagedestroy()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iLL
    New Member
    • Oct 2006
    • 63

    imagedestroy()

    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

    Code:
    function addThumb($file)
    {
    	global $dirPath;
    	global $thumbPath;
    
    	$size		= getimagesize($dirPath.$file);		//Image size
    	$thumbWidth	= 200;					//New width.
    	$thumbHeight	= ($thumbWidth/$size[0]) * $size[1];	//New height
    
    	$thumb		= imagecreatetruecolor($thumbWidth, $thumbHeight);	//New Image
    	$source		= imagecreatefromjpeg($dirPath.$file);			//Open Image
    
    	imagecopyresized($thumb, $source, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $size[0], $size[1]);	//resize $source and save it in $thumb
    	imagejpeg($thumb,$thumbPath.$file);	//save $thumb
    }
    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?
  • kovik
    Recognized Expert Top Contributor
    • Jun 2007
    • 1044

    #2
    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.

    Comment

    Working...