| re: GD library memory problem
Christian Giordano wrote:
Hi Christian,
This question is posted once every day, it seems.
(Is it in the FAQ alreadY?)
[color=blue]
> Hi guys I've just tryed to upload a 1 MB image and resize it in a new
> hosting (media temple) and it gives me this error:
>
> Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
> allocate 6400 bytes) in /home/httpd/vhosts/....php
>
> where with the GD Library a create a kind of copy:
>
> $source = imagecreatefromjpeg($file);
>
> Does someone know how to solve this issue?
>[/color]
The problem lies in the fact that you assume that a 1 megabyte image takes
up 1 magebyte of internal memory.
This is not the case.
First the image is compressed, so if PHP needs an internal representation of
all pixels, it needs to unpack it.
A rude estimate:
If your image is 100 x 500 pixels:
that is 50.000 pixels
Every pixel needs 24 bits to store (RGB+alpha)
So you need 1.200.000 bytes (around 1.2 meg)
How to fix it?
Increase the memory that PHP can allocate (in php.ini) or work with smaller
files (if possible).
Regards,
Erwin Moller
[color=blue]
>
> cheers, chr[/color] |