Any ideas why I'm getting ....
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to
allocate 9792 bytes) in /home/frich/public_html/creation/systemc/sMain/upload_image.php on line 77
on the following line
$oldImage = imagecreatefromjpeg($img);
The php grabs an image from a HTML form and resizes it.
Works perfectly fine if its a small file. I.e. a few hundred KB
Tried with a larger file as I want a max of up to 4mb. The image I get an error with is ca. 2mb
Thanks in advance
You are getting error
""""""""""""""""""""""""
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to
allocate 9792 bytes) in /home/frich/public_html/creation/systemc/sMain/upload_image.php on line 77
""""""""""""""""""""""""
It shows that either you are using a shared hosting because your server memory_limit is 32 MB
You need to increase your memory limit as said above by "Pekka" and "MartyIX"
but how you do this there are three ways of doing so.
they will increase it upto 48MB max that is the restriction of any hosting company for sheared hosting acount.
with written "memory_limit = 100M and max_memory = 100M"
you can change 100M to any size that you want but that can be in limit so that it will not use extra resources of server else your account may be suspended by your hosting company
LIMITATION: this option may not work properly on every hosting because some times this code may be blocked by admin so that server resources may be consumed in LIMIT.
written inside it "php_value memory_limit 32M"
or
by default it is available in your hosting web directory then you can first download it as it is having other settings too. download it open it with notepad and write "php_value memory_limit 32M"
and
"ini_set('memory_limit', '32M');" (Not tested yet by me, may it work fine)
Thanks and Regards........
The image you are trying to process is too large for the 32 MB memory limit your script has.
Resizing an image takes up at least
(width in pixels) x (height in pixels) x 3 (or 4)
bytes (1 byte each for Red / Green / Blue, possible one additional byte for transparency)
You need to increase the memory_limit
setting on the server, or ask the administrator to do so.
32MB is a pretty decent and common value, though - you may be out of luck if you're on shared hosting.
Alternatively, if possible on your server, use ImageMagick, whose memory consumption does not count toward the memory_limit
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With