Page 1 of 1

[SOLVED] imagecreatefromjpeg and large dimensions

Posted: Sun Jun 19, 2005 5:52 am
by usr.c
Hi guys,

Nice place you have here. First poster.

I've got a problem with imagecreatefromjpeg() dying with an internal server error on images with fairly large dimensions (say 2000x1500). My resoures in php.ini are set fairly high and I've noticed that large dimensions make it fall over and not file sizes. Anyone have any clue as to what might be causing this or if it's indeed a known issue? I've narrowed down the problem in the script to the line containing imagecreatefromjpeg(), so I know it's the culprit.

I'm running PHP 4.3.10 (compiled with all the supporting GD stuff) on rh9.

Thanks for any pointers.

Posted: Sun Jun 19, 2005 6:28 am
by onion2k
It is almost certainly doing one of two things. Either it's running into PHP's memory limit (http://uk.php.net/manual/en/ini.core.ph ... mory-limit), or the script is timing out (http://uk.php.net/manual/en/ref.info.ph ... ution-time). What settings do you have for these?

I've created images much large that that using GD2. It definitely can handle things that size.

Posted: Sun Jun 19, 2005 7:01 am
by usr.c
hmmm...I've max_execution_time and max_input_time at 120 and the memory limit at 64M. The picture's actually quite small (80KB), and the script gives the 500 error only a few seconds after I upload it, which makes me wonder if it's indeed a resource problem. Other pictures that are 1024x768 and over 1MB upload just fine.

Any other ideas? Thanks.

Posted: Sun Jun 19, 2005 7:45 am
by timvw
What do you recieve if you prepend the following to your code?

Code: Select all

ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);

Posted: Sun Jun 19, 2005 8:58 am
by usr.c
The problem is that the 500 error is displayed right after the function is called so there's no chance to see what the errors might be. php.ini is already set up to pipe all errors to the browser.

Posted: Sun Jun 19, 2005 9:04 am
by onion2k
usr.c wrote:The picture's actually quite small (80KB)
The compressed image file is quite small, but GD has to decompress it in order to do anything to it.. that's when it starts taking up big chunks of memory.

Posted: Sun Jun 19, 2005 9:09 am
by timvw
Might want to tail /var/log/apache/error.log (or wherever you keep it..)

Posted: Sun Jun 19, 2005 1:04 pm
by usr.c
Spot on. Makes me wonder why I didn't look in the error logs to begin with. There was an error parsing php.ini because of a line that had split across two lines.

All's well now. Thanks both for the replies.