garydt Posted August 28, 2007 Share Posted August 28, 2007 I have this resize script: it works on smaller images but on larger images - over 2400 pixels wide, it uses too much memory $filename = './uploads/'.$name; if(file_exists($filename)) { $image = imagecreatefromjpeg($filename); //unresized image $im_info = getimagesize($filename); //unresized image $im_width = $im_info[0]; $im_height = $im_info[1]; $im_flag = $im_info[2]; //max height: 140px; max width: 140px if($im_width >= $im_height) { $im_divice = $im_width / 140; }else { $im_divice = $im_height / 140; } $thumb_width = $im_width / $im_divice; $thumb_height = $im_height / $im_divice; //create empty image $thumb = imagecreatetruecolor($thumb_width, $thumb_height); //resize image imagecopyresampled($thumb, $image, 0, 0, 0, 0, $thumb_width, $thumb_height, $im_width, $im_height); if(imagejpeg($thumb, "thumbnails/".$name, 80)) { //image-resource, filename, quality return 1; } imagedestroy($thumb); //destroy temporary image-resource imagedestroy($image); //destroy temporary image-resource } is there another way to resize images. My server only allocates 20M. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/67072-resize-script-uses-too-much-memory/ Share on other sites More sharing options...
tippy_102 Posted August 28, 2007 Share Posted August 28, 2007 You should look at the php.net page for imagecreatefromjpeg. Many of the User Contributed Notes discuss this issue, and how to deal with it. Quote Link to comment https://forums.phpfreaks.com/topic/67072-resize-script-uses-too-much-memory/#findComment-336467 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.