php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65070 imagerotate and wrong background color
Submitted: 2013-06-20 15:41 UTC Modified: 2013-06-20 19:54 UTC
From: david at grudl dot com Assigned: pajoye (profile)
Status: Closed Package: GD related
PHP Version: 5.5.0 OS: Windows
Private report: No CVE-ID: None
 [2013-06-20 15:41 UTC] david at grudl dot com
Description:
------------
When is non-truecolor image rotated, it is converted to truecolor. Problem is with background color. In PHP < 5.5 is used correct color, exactly as choosed using imagecolorallocatealpha(), but in PHP 5.5 is used wrong color, probably closest color in palette.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-20 16:18 UTC] pajoye@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: pajoye
 [2013-06-20 16:18 UTC] pajoye@php.net
It copies pixel by pixel using the colors defined by the color index.

I will check it again but 1st test did not reproduce this problem.

If you have a self contained script to show how this problem occurs in your app, 
please post it here.
 [2013-06-20 16:18 UTC] pajoye@php.net
-PHP Version: 5.5.0RC3 +PHP Version: 5.5.0
 [2013-06-20 16:32 UTC] david at grudl dot com
Example code:


$im = imagecreatefromgif('logo-white.gif'); // http://files.nette.org/icons/logo-white.gif
$res = imagerotate($im, 30, imagecolorallocatealpha($im, 0, 0, 0, 0)); // black
imagepng($res, 'result.png');  // background is blue


PHP 5.5.0  (Thu, 20 Jun 2013 00:29:47)
Build: C:\php-sdk\php55\vc11\x86\obj\Release_TS
 [2013-06-20 19:54 UTC] pajoye@php.net
There are two problems in the current code, which could be a BC break tho'

1. The source image has not transparent color set
2. imagerotate expects a truecolor color (ARGB)

I think 2. is a BC break and should consider the input format as matching the 
source image color format. Fix on its way :)
 [2013-06-20 20:33 UTC] pajoye@php.net
Automatic comment on behalf of pierre.php@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c65d663aefd27e39006b9c20a665893aa5265ed4
Log: fix #65070, bgcolor does not use the same format as the input image with imagerotate
 [2013-06-20 20:33 UTC] pajoye@php.net
-Status: Feedback +Status: Closed
 [2013-06-20 20:33 UTC] pajoye@php.net
Automatic comment on behalf of pierre.php@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=07e52857b5f7a65c1552628e14a8a6aeeea24508
Log: fix #65070, bgcolor does not use the same format as the input image with imagerotate
 [2013-06-20 20:34 UTC] pajoye@php.net
Automatic comment on behalf of pierre.php@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c65d663aefd27e39006b9c20a665893aa5265ed4
Log: fix #65070, bgcolor does not use the same format as the input image with imagerotate
 [2013-06-20 20:34 UTC] pajoye@php.net
Automatic comment on behalf of pierre.php@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=07e52857b5f7a65c1552628e14a8a6aeeea24508
Log: fix #65070, bgcolor does not use the same format as the input image with imagerotate
 [2013-11-17 09:30 UTC] laruence@php.net
Automatic comment on behalf of pierre.php@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c65d663aefd27e39006b9c20a665893aa5265ed4
Log: fix #65070, bgcolor does not use the same format as the input image with imagerotate
 [2013-11-17 09:30 UTC] laruence@php.net
Automatic comment on behalf of pierre.php@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=07e52857b5f7a65c1552628e14a8a6aeeea24508
Log: fix #65070, bgcolor does not use the same format as the input image with imagerotate
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC