Hello, I am trying to resize an image using php. I admit the image is a very big one in tems of dimension. The file size is only 3.5mb. Although when I do I receive this error message: Fatal error: Out of memory (allocated 42729472) (tried to allocate 4272 bytes) in blah blah blah on line 101 PHP: The code is: //surely 1024M is plenty big enough to create any image? ini_set("memory_limit","1024M"); $newimage = imagecreatetruecolor($newwidth, $newheight); if($filetype == 'image/jpeg') { $image = imagecreatefromjpeg($dir.$filename); //This is line 101 } else if($filetype == 'image/gif') { $image = imagecreatefromgif($dir.$filename); } else if($filetype =='image/png') { $image = imagecreatefrompng($dir.$filename); } imagecopyresampled($newimage, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); PHP: The image uploads to the server fine. Its just on the new image creation method where it throws errors. I can increase the memory allocated although, If I take it too big it just silently fails and does not process the image at all. Is there a way round this or am I just going to have to take the images in to photoshop and resize it there to size which the server memory can handle. Which kind of defeats the object of the script. Sorry if your not understanding my problem. I am very new to php and am still learning basic stuff. You can test the site here -> www.expressthumbnails.com Thank you. - Methok
I just tried your resizer and it worked great. I uploaded a 1920x1080 24-bit image. Disk size is 1.5 MB, but actual image size is around 6 MB. So that's well within your 1 GB memory limit I'd reduce that to 32 MB. The physical file size of 3.5 MB doesn't mean much. You must have uploaded an image with VERY big dimensions. What size was it exactly? Can you send it to me?
Yes it was a very big in dimensions. Straight out my 12 million pixel camera. 4272 by 2848 Pixels. Thats 150.71 by 100.47 cm. If it can handle that then it ca handle pretty much anything. BUT. I have solved it now using ImageMagick Thank you Sergey.