Image resize not working in some cases on 5.2.0

12 views
Skip to first unread message

Alexander Obuhovich

unread,
Jul 26, 2012, 2:07:00 PM7/26/12
to Bugs In-Portal
In most cases images are sized properly, but image I've attached didn't resize and is producing following errors in debugger:

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: 359094 extraneous bytes before marker 0xd9 in w:\in-portal\core\units\helpers\image_helper.php on line 188
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '.../system/images/Buddy on the porch.jpeg' is not a valid JPEG file in w:\in-portal\core\units\helpers\image_helper.php on line 188

At first I though image is broken, but it'd GD & libjpeg thinks what way. I can open that image on my PC using any program, even Photoshop.

Line, where error is happening says:
$src_image_rs = imagecreatefromjpeg($src_image);

I thought that I need to update JPEG library, but I already have latest version 6b from 1998 year.


--
Best Regards,

http://www.in-portal.com
http://www.alex-time.com
Buddy on the porch.jpg

Alexander Obuhovich

unread,
Jul 26, 2012, 2:28:31 PM7/26/12
to Bugs In-Portal
After a little bit of digging I was able to find this https://bugs.php.net/bug.php?id=29878 bug report, that explained a problem in GD being too strict about reading a bit broken JPEG images.

This is the code that solves a problem (highlighted line):

error_reporting(E_ALL);
// 0 is the current behavior
ini_set('gd.jpeg_ignore_warning', 1);
$im = imagecreatefromjpeg($file);



Ready for testing.
resizing_of_corrupted_jpeg_images_fix.patch
Reply all
Reply to author
Forward
0 new messages