|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-12-21 02:34 UTC] hnthanhphong at yahoo dot com
Description: ------------ I use PHP 5.2 and GD version bundled (2.0.28 compatible). When I use function imagecreatefromjpeg to create a thumbnail but it doesn't work with only one jpeg file. I don't know why? You can get this jpeg file from http://www.vietmy.com.vn/tmp/test.jpg Actual result: -------------- Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: 321 extraneous bytes before marker 0xd9 in C:\Source\lib\lib.php on line 129 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'C:\ModelMayhem\Source/userphotos/8_48_R.JPG' is not a valid JPEG file in C:\Source\lib\lib.php on line 129 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 22:00:01 2025 UTC |
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.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.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; }