Bug #66882 [Opn]: imagerotate by -90 degrees truncates image by 1px
| From: | cmb@php.net | Date: | Sun, 12 Jul 2015 21:30:16 +0000 |
| Subject: | Bug #66882 [Opn]: imagerotate by -90 degrees truncates image by 1px | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194361@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66882&edit=1
ID: 66882
Updated by: cmb@php.net
Reported by: jarrod at makin dot co
Summary: imagerotate by -90 degrees truncates image by 1px
Status: Open
Type: Bug
Package: GD related
Operating System: RHEL6.5
PHP Version: 5.5.10
Block user comment: N
Private report: N
New Comment:
Might be a duplicate of bug #65148.
Previous Comments:
------------------------------------------------------------------------
[2014-03-12 04:35:41] phpmpan at mpan dot pl
A typo. I meant
gdImageRotateBilinear of course, not gm....
------------------------------------------------------------------------
[2014-03-12 04:34:16] phpmpan at mpan dot pl
Confirmed for master snapshot and 5.5.10.
A quick dive into the code suggests gmImageRotateBilinear contains code that handles
floats inproperly by casting them to int (hence truncating) where extracting integer
part was probably meant.
Minimal code:
$image = imagerotate(imagecreate(10, 10), -90, 0)
echo imagesy($image), 'x', imagesx($image)
If the source image has size of 1x1, the effects are even worse, as the functions below receive 0 as
size.
------------------------------------------------------------------------
[2014-03-11 15:17:28] jarrod at makin dot co
Description:
------------
Rotating an image anticlockwise by -90 degrees (clockwise 90 degrees) produces an image that is 1px
narrower than you would expect and the left most vertical column of pixels are all black.
However, rotating an image anticlockwise by 270 degrees (also clockwise 90 degrees) produces an
image of the correct dimensions and without the line of black pixels.
Test script:
---------------
Source
http://www.jarrodmakin.com/imagerotate.txt
Usable test script
http://www.jarrodmakin.com/imagerotate.php
Expected result:
----------------
Paraphrasing:
Dimensions are A x B
Dimensions of rotation are B x A
Actual result:
--------------
Paraphrasing:
Dimensions are A x B
Dimensions of rotation are B x (A - 1)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66882&edit=1