#29482 [NEW]: imagecreatefrompng() throws fatal error (no warning) when opening broken images

From: Date: Sun, 01 Aug 2004 13:55:53 +0000
Subject: #29482 [NEW]: imagecreatefrompng() throws fatal error (no warning) when opening broken images
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-63878@lists.php.net to get a copy of this message
From: troublegum at woltlab dot de Operating system: Windows XP Professional PHP version: 5.0.0 PHP Bug Type: GD related Bug description: imagecreatefrompng() throws fatal error (no warning) when opening broken images Description: ------------ imagecreatefrompng() should not throw a fatal error when opening broken image files. Instead, a warning would be much more useful. The following code is useless as the scripts dies without any output. If I remove the @, it throws the following message: --- Fatal error: imagecreatefrompng() [function.imagecreatefrompng]: gd-png: fatal libpng error: Invalid chunk length. in F:\htdocs\bug\read.php on line 3 --- imagecreatefrompng throws a warning when opening files that are no png files ('broken.png' is not a valid PNG file) but not when the image file is a png image, bug is broken for whatever reason. --- OS: Windows XP Professional Apache: 2.0.49 PHP: 5.0.0 as apache module GD: bundled (2.0.23 compatible) PNG Support: enabled Reproduce code: --------------- <?php $filename = 'broken.png'; $imageResource = @imagecreatefrompng($filename); if (!$imageResource) { die('could not read ' . $filename . ' image'); } else { echo 'image ' . $filename . ' successfully read'; } ?> Expected result: ---------------- could not read broken.png image Actual result: -------------- Fatal error: imagecreatefrompng() [function.imagecreatefrompng]: gd-png: fatal libpng error: Invalid chunk length. in F:\htdocs\bug\read.php on line 3 -- Edit bug report at http://bugs.php.net/?id=29482&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29482&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29482&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=29482&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29482&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29482&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29482&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29482&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29482&r=support Expected behavior: http://bugs.php.net/fix.php?id=29482&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29482&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29482&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29482&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29482&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29482&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29482&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29482&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29482&r=float

« previous php.bugs (#63878) next »