[SOLVED] imagecreatefromjpeg and large dimensions

Need help with Photoshop, the GIMP, Illustrator, or others? Want to show off your work? Looking for advice on your newest Flash stuff?

Moderator: General Moderators

Post Reply
User avatar
usr.c
Forum Newbie
Posts: 4
Joined: Sun Jun 19, 2005 3:49 am

[SOLVED] imagecreatefromjpeg and large dimensions

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
usr.c
Forum Newbie
Posts: 4
Joined: Sun Jun 19, 2005 3:49 am

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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);
User avatar
usr.c
Forum Newbie
Posts: 4
Joined: Sun Jun 19, 2005 3:49 am

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Might want to tail /var/log/apache/error.log (or wherever you keep it..)
User avatar
usr.c
Forum Newbie
Posts: 4
Joined: Sun Jun 19, 2005 3:49 am

Post 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.
Post Reply