php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40069 resizing png
Submitted: 2007-01-09 00:57 UTC Modified: 2007-01-10 12:46 UTC
From: alex at gateway-productions dot com Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: latest cvs OS: Linux
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: alex at gateway-productions dot com
New email:
PHP Version: OS:

 

 [2007-01-09 00:57 UTC] alex at gateway-productions dot com
Description:
------------
imagecopyresampled() returns a blank resized image with alpha not the source resized with alpha


Reproduce code:
---------------
       $im = ImageCreateFromPNG($sourcefile);
       $im_dest = imagecreatetruecolor ($sourcefile_new_width, $sourcefile_new_height);
       imagealphablending($im_dest, false);
       imagecopyresampled($im_dest, $im, 0, 0, 0, 0, $sourcefile_width, $sourcefile_height, $sourcefile_new_width, $sourcefile_new_height);
       imagesavealpha($im_dest, true);
       imagepng($im_dest, $destfile);
       imagedestroy($im_dest);

Expected result:
----------------
resizing actuall source png while keeping transparency and saving file

Actual result:
--------------
returns a blank resized image with alpha not the source resized with alpha


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-09 00:59 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2007-01-09 01:47 UTC] pajoye@php.net
If it does not work with the snapshots, please provide a source image (a link to).
 [2007-01-10 09:31 UTC] alex at gateway-productions dot com
upgraded to latest cvs version, and i have the latest gd

and still does not produced desired outcome unless my code is wrong? it is still not transfering the overlayed none alpha data.

heres a link to the orginal watermark

http://gateway-productions.com/v6/media/gallery/watermark.png
 [2007-01-10 09:33 UTC] alex at gateway-productions dot com
this is the output png code example

http://gateway-productions.com/v6/media/gallery/test.png
 [2007-01-10 09:39 UTC] alex at gateway-productions dot com
after closer inspection of the png i noticed that it is possibly transfering correctly,. As you can see what appears to be a bit of the picture on the bottom left, but it is not resizing the png at all. 

rather overlaying without resizing the overlayed image.
 [2007-01-10 12:46 UTC] pajoye@php.net
I suppose you are trying to resize an image (which has alpha). It works well here.

See:
http://blog.thepimp.net/misc/40069_res.png

You inverted the width/height arguments in imagecopyresampled. The correct script should be (size * 1.2 here):

$im = imagecreatefrompng($sourcefile);

$sourcefile_width = imagesx($im);
$sourcefile_height = imagesy($im);

$sourcefile_new_width = $sourcefile_width * 1.2;
$sourcefile_new_height = $sourcefile_height * 1.2;

$im_dest = imagecreatetruecolor ($sourcefile_new_width, $sourcefile_new_height);
imagealphablending($im_dest, false);
imagecopyresampled($im_dest, $im, 0, 0, 0, 0, $sourcefile_new_width, $sourcefile_new_height,
    $sourcefile_width, $sourcefile_height);

imagesavealpha($im_dest, true);
imagepng($im_dest, $destfile);
imagedestroy($im_dest);

I close the bug (no bug > bogus), feel free to reopen it if I misunderstand your problem,

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 01 01:01:28 2024 UTC