[Solved] GD Library issues with file size.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

determinedmoth wrote:Ok this is interesting. I took an image that has been failing, and saved it as a severly compressed JPG - down to 89kb! This also failed! So the memory limit being the problem could just be a red herring. Maybe it's something to do with the image dimensions.
The filesize of an image is basically meaningless when you're using GD. It decompresses the image data in order to work on the it .. a 1000*1000 image will take up the same amount of RAM whether it's a JPG saved at quality 100 or a JPG saved at quality 30.
determinedmoth
Forum Commoner
Posts: 33
Joined: Wed Jul 07, 2004 9:13 am

Post by determinedmoth »

The host has upgraded me to PHP5 (GD - 2.0.28 compatible).

It now works somewhat better, but rather just failing I now get some errors;
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /xxx/xx/xxx/xxxx/xx/admin.php on line 162

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '/xxx/xx/xxx/xxxx/xx/images/lowres/fb6_Picture 078a.jpg' is not a valid JPEG file in /xxx/xx/xxx/xxxx/xx/admin.php on line 162

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /xxx/xx/xxx/xxxx/xx/admin.php on line 163
Line 162 & 163;

Code: Select all

$image = imagecreatefromjpeg($newfile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
determinedmoth
Forum Commoner
Posts: 33
Joined: Wed Jul 07, 2004 9:13 am

Post by determinedmoth »

Solved I believe!

After trying various options in Photoshop;

You need to resave the jpg (save-as), and at the compression options box, select format as "Baseline ("Standard")".

I yet to have it fail.

Thanks everyone for your help.

*Edit: Removed.

**Edit:

Fix will work for GD v.2.0.28

GD v.2.0 will still fail.
Last edited by determinedmoth on Fri Feb 24, 2006 9:25 am, edited 1 time in total.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

determinedmoth wrote:*Edit: Fix only for PHP5! Will still fail on PHP4.
It's a lot more likely to be related to the version of GD than the version of PHP if it's related to the JPEG file layout.
determinedmoth
Forum Commoner
Posts: 33
Joined: Wed Jul 07, 2004 9:13 am

Post by determinedmoth »

I agree. I should re-word that.

Fix will work for GD v.2.0.28

GD v.2.0 will still fail.
Post Reply