php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32921 ImageRotate() lost of alphalayer
Submitted: 2005-05-03 08:44 UTC Modified: 2006-01-24 11:34 UTC
Votes:5
Avg. Score:4.4 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: eckounlimited at gmx dot nnet Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 5CVS-2005-05-02 (dev) OS: *
Private report: No CVE-ID: None
 [2005-05-03 08:44 UTC] eckounlimited at gmx dot nnet
Description:
------------
Imagerotate between -45 an 45 degree including an alphachannel is no problem! 46 to -44 ist still replacing the background with black.
Ohh i forgot: If you rotate, you have to specify an backgroundcolor by imagecolorallocatealpha(!) and set imagealphablending to false and imagesavealpha to true to get an transparent rotated png...

Reproduce code:
---------------
<?PHP
$rot = 35;
$i = imagecreatetruecolor(300,300);
imagealphablending($i, FALSE);
imagesavealpha($i,TRUE);
$whitetrans = imagecolorexactalpha($i,255,255,255,127);
imagefilledrectangle($i,0,0,200,200,$whitetrans);
$o = imagecreatefrompng("./rotate.png");
$o = imagerotate($o,$rot,$whitetrans,0);
imagecopyresampled($i,$o,0,0,0,0,300,300,300,300);
imagepng($i,"test".$rot.".png");
?>

Expected result:
----------------
This works fine and copys a transparent PNG with 35 degree to the new test.png.
If you change now $rot = 35 to $rot = 46 the rotated png will appear on an black background.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-06 03:17 UTC] sniper@php.net
Are you using bundled gd library or external one?
(what do you pass to --with-gd configure option?)

 [2005-05-06 18:56 UTC] pajoye@php.net
Hi,

Partially fixed in CVS, will commit asap the definitive fix, keeping BC.

--Pierre
 [2005-05-14 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-01-24 11:28 UTC] test at test dot com
consider this as a bug or just gd's weaknessess:

- imagerotate is not alpha-able
- any animation picture (gif) is not properly rotated and not alpha-able too

need to upgrade this function
 [2006-01-24 11:34 UTC] pajoye@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Alpha channel is *not* the background color, neither the transparent color (gif).

Try CVS snapshot and give valid mail. If it still fails, reopen this bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 22:01:29 2024 UTC