Jump to content

Recommended Posts

Error message: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 9088 bytes)

 

I always get this error message when doing a file upload with a imagecopyresampled() & imagecreatefromjpeg() function if the image large in dimensions (NOT filesize) i.e. a 3000x3000px image will fail whether it is 50kb or 50MB but a 200x200 image will be fine, even if it is 300MB.

 

I understand that the user resizing their image down a bit would solve this - is there a solution? I can only increase memory limit so much. The likes of facebook don't seem to have any trouble. Is it because the upload and resampling /resizing of the image is done in one go?

 

If the only solution is to have the user resize before uploading, is there a way I can alert them before running the script to the point of error? I know when I am checking if a file is too large that I have to let the script upload the file first, then get the size and show the message. But I don't know how I can do this for the dimensions. Especially since I don't really know what the limits are before it does run out of memory.

 

Any help greatly appreciated. I am not posting any code as this seems to happen with any image upload code I have used that uses imagecopyresampled,imagecopyresized, imagecreatefromjpeg and move_uploaded_file and it is more of a general question.

Hi deansatch,

 

dimension of image has no impact on file size. So when you are uploading file is doesn't matter whether dimension is 3000x3000 or 3x3.

 

But in my opinion, when you are try to transform image, the problem with big-dimention images can occurs.

 

You can check the image dimension just before transform it.

 

Or maybe you will try Image Magick insteed of GD?

 

Regards

Cezar708

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.