php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22388 resizing png images results not working
Submitted: 2003-02-23 19:09 UTC Modified: 2003-03-09 19:08 UTC
Votes:10
Avg. Score:4.7 ± 0.6
Reproduced:9 of 10 (90.0%)
Same Version:6 (66.7%)
Same OS:5 (55.6%)
From: don at seiler dot us Assigned:
Status: No Feedback Package: GD related
PHP Version: 4.3.0 OS: gentoo linux 2.4.20
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: don at seiler dot us
New email:
PHP Version: OS:

 

 [2003-02-23 19:09 UTC] don at seiler dot us
mod_php 4.3.x is failing to properly resize a png image.  It outputs no errors but the resulting image is just a single color, which obviously would be nothing like the original photograph.

My code works perfectly fine on mod_php 4.2.3 with the gd patch.

here is the code I use for png resizing, I actually output to a new image, basically thumbnail creation.

$orig_image = "/path/to/orig_image.png";
$thumb_image = "/path/to/thumb_image.png";
/* code to get image dimensions and thumb image dimensions here */

$src_image = imagecreatefrompng($orig_image);
$dst_image = imagecreate($dst_width, $dst_height);
imagecopyresized($dst_image, $src_image, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
imagepng($dst_image, $thumb_image);
imagedestroy($src_image);
imagedestroy($dst_image);

As I said this code behaves fine on 4.2.3.  On 4.3.0 and 4.3.1 it outputs a single-color image/png file.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-23 19:10 UTC] don at seiler dot us
Just noting that it does resize jpeg images just fine.
 [2003-02-23 20:07 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

I've tried your test script with latest CVS and it works fine.
If the problem persists please indicate which GD are you using (built-in or native) as well as what version of libpng your php/gd are linked against?
 [2003-02-23 20:58 UTC] don at seiler dot us
OK I'll have to make a gentoo ebuild to try that out.

Just an FYI, using imagecreatetruecolor() instead of imagecreate() fixed this problem.  It seems that php's built-in gd is a little more strict with png color information.

Gentoo's mod_php ebuild uses the built-in gd for 4.3.x.
 [2003-02-23 21:19 UTC] iliaa@php.net
As a rule you probably should not use imagecreate() when dealing with potentially truecolor images like pngs. Instead use imagecreatetruecolor().

P.S. please keep the report status as feedback until you've had the chance to try the latest CVS.
 [2003-03-09 19:08 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2003-11-27 01:11 UTC] 336764 at 163 dot com
Me too!
 [2003-11-27 01:12 UTC] 336764 at 163 dot com
JPEG is worrking, it can resize & display.
but png is working not . :( output is only once color pic.
 [2003-11-27 01:15 UTC] 336764 at 163 dot com
at php5.0.0b2 is working
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 05:01:27 2024 UTC