ImageCreateFromJPEG() – Allowed memory exhausted…

When using ImageCreateFromJPEG (e.g. if I want to resize an image) an uncompressed version of the image is stored in the memory. As a consequence, a 100 kb image (dimensions 5000×5000) may consume the entire memory_limit and therefore be rejected (Fatal error: Allowed memory size of xxxxxxxx bytes exhausted…), while a 900 kb image (1000×1000) may upload without any problems.

The easy solution would be to increase memory_limit etc. in php.ini, but if we are looking at really large dimensions this is not always a good solution. It would consume a lot of memory and could eventually slow down the server.


I use ini_set(‘memory_limit’, ‘-1’);, though.

By karuppasamy11486 Posted in php

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s