Bug #39918 [Com]: imagecreatefromjpeg doesn't work

From: Date: Wed, 23 Apr 2014 10:44:40 +0000
Subject: Bug #39918 [Com]: imagecreatefromjpeg doesn't work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185379@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=39918&edit=1

 ID:                 39918
 Comment by:         spam2 at rhsoft dot net
 Reported by:        hnthanhphong at yahoo dot com
 Summary:            imagecreatefromjpeg doesn't work
 Status:             Not a bug
 Type:               Bug
 Package:            GD related
 Operating System:   Linux
 PHP Version:        5.2.0
 Assigned To:        pajoye
 Block user comment: N
 Private report:     N

 New Comment:

in case of a "recoverable error" i expect that a *WARNING* don't lead in the
following code be broken for several reasons:

* it is just a warning and not a fatal error
* read the source image works
* the broken metadata of some cameras are removed in the gd-generated thumbnail
* the current behavior breaks the intention of gd for resize images

$src_img = @imagecreatefromjpeg($src_path);
if($src_img)
{
 // code to resize an image
}
else
{
 return false;
}


Previous Comments:
------------------------------------------------------------------------
[2006-12-22 02:10:56] hnthanhphong at yahoo dot com

ini_set("gd.jpeg_ignore_warning", 1);
This code is useful. Now I can make sure that my page always works.
Thanks you for your help.

------------------------------------------------------------------------
[2006-12-21 12:12:27] pajoye@php.net

GD does provide a mechanism to be more tolerant with broken jpeg images.

Using error_reporting(E_ALL); while developing would have told you what's going on. GD did
report some errors in the jpeg codec. Some of the jpeg errors are recoverable, like those in this
image.

You can change the behaviors of the jpeg codec using gd.jpeg_ignore_warning:

ini_set("gd.jpeg_ignore_warning", 1);
$im = imagecreatefromjpeg("test.jpeg");

$im contains now your image.


------------------------------------------------------------------------
[2006-12-21 09:49:15] hnthanhphong at yahoo dot com

I re-saved in Photoshop, and post again it works property.
Thank you very much.

------------------------------------------------------------------------
[2006-12-21 09:43:53] derick@php.net

Photoshop also "repairs" broken JPEGs, PHP does not do that, and will never do that. I bet
if you re-save it in Photoshop PHP can read it as well.

------------------------------------------------------------------------
[2006-12-21 09:26:22] hnthanhphong at yahoo dot com

But I open this file in photoshop. It works no problem.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=39918


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=39918&edit=1


Thread (9 messages)

« previous php.bugs (#185379) next »