php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14350 gd cant handle some png files
Submitted: 2001-12-05 08:48 UTC Modified: 2002-06-07 07:43 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: martin at humany dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.0.6 OS: win2000
Private report: No CVE-ID: None
 [2001-12-05 08:48 UTC] martin at humany dot com
(Im using the official php 4.0.6 build for windows from php.net, only extension loaded is php_imap.dll).
I've written a function to rezise images (used for making thumbnails), it's working fine, also with png-files, but not all. Below is the code to reproduce the problem:


jul.png is working properly, download from http://inthc.net/jul.png

gba_large.png is NOT working properly, download from http://inthc.net/gba_large.png

(gba_large.png result in a full blue window, or a full black or gray, it changes upon reload..)
gba_large.png was created with Paint Shop Pro 7, and displays fine in IE, Netscape & Opera.

----snip start--
//$filename = "jul.png";
$filename = "gba_large.png";

$inImg = @ImageCreateFromPNG($filename);
if (!$inImg) { echo "Failed to open png!"; die; }

$size = GetImageSize($filename);
$srcW = $size[0]; $srcH = $size[1];
$dstW = 100; $dstH = 100;
$outImg = @ImageCreate($dstW, $dstH);
ImageCopyResampled($outImg, $inImg, 0,0,0,0, $dstW, $dstH, $srcW, $srcH);
		
header("Content-type: image/x-png");
ImagePNG($outImg);
---snip end--

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-14 07:22 UTC] aj at haightmail dot org
PHP 4.1.2-1
libgd 2.0.1-7
Apache 1.3.23-1
Linux, Debian Woody with libgd package selected from Sid

I experience problems using both ImageCopyResampled and  ImageCopyResized on all PNGs loaded with ImageCreateFromPNG.

Source images that have a transparent background yield an all black result image, no matter the source and destination sizes. The error is either in ImageCreateFromPNG or the resize/resample functions, I do not know which.

Other PNG images yield correct results when the destination size is smaller than the source size, but generate garbage when the destination is larger than the source.

JPEGs loaded with ImageCreateFromJpeg, on the other hand, always work.
 [2002-06-07 07:43 UTC] edink@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC