Bug #65148 [Opn->Csd]: imagerotate may alter image dimensions

From: Date: Tue, 24 Oct 2017 15:30:33 +0000
Subject: Bug #65148 [Opn->Csd]: imagerotate may alter image dimensions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212283@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65148&edit=1 ID: 65148 Updated by: cmb@php.net Reported by: imprec at gmail dot com Summary: imagerotate may alter image dimensions -Status: Open +Status: Closed Type: Bug Package: GD related PHP Version: 5.5+ Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=php-src.git;a=commit;h=22c487616f132ee7ebfa838bce9d14c9243bd2d3 Log: Fixed bug #65148 (imagerotate may alter image dimensions) Previous Comments: ------------------------------------------------------------------------ [2016-09-05 11:47:32] cmb@php.net This has apparently been fixed as of libgd-2.2.2[1], but not yet been integrated to PHP's bundled libgd. @pajoye If this issue is considered to be bug, the patch should probably applied to PHP-5.6+. [1] <https://github.com/libgd/libgd/commit/6267414d> ------------------------------------------------------------------------ [2016-04-16 15:52:59] pajoye@php.net The cause was slightly different. The calculation of the transformed image dimensions were partially wrong. If you can try this patch, that should fix your issue: https://gist.github.com/pierrejoye/59d72385ed1888cf8894a7ed437235ae ------------------------------------------------------------------------ [2016-04-11 05:38:08] pajoye@php.net It seems to be only for the default interpolation method, IMG_BILINEAR_FIXED. Adding: imagesetinterpolation($image, IMG_BICUBIC); before calling imagerotate shows the correct result. IMG_BICUBIC_FIXED for example works well too. I have to check if other are affected but my feeling is that only the bilinear fixed point implementation fails. If you have time, you can also try it. The various interpolation methods are available here: http://php.net/manual/en/function.imagesetinterpolation.php ------------------------------------------------------------------------ [2016-04-09 10:51:38] plunk at hushmail dot com The top and left of the image is actually clipped. This problem appears at all rotations: <?php $image = imagecreatetruecolor(500,250); $bg = imagecolorallocatealpha($image, 255, 255, 127, 127); $black = imagecolorallocatealpha($image, 0, 0, 0, 0); $blue = imagecolorallocatealpha($image, 0, 0, 255, 0); $red = imagecolorallocatealpha($image, 255, 0, 0, 0); imagesavealpha($image, true); imagealphablending($image, false); ImageFill($image, 0, 0 , $bg); imagerectangle($image,0,0,imagesx($image)-1,imagesy($image)-1,$black); imagerectangle($image,1,1,imagesx($image)-2,imagesy($image)-2,$blue); imagerectangle($image,2,2,imagesx($image)-3,imagesy($image)-3,$red); imagepng($image,'dump1.png'); echo '<img src="dump1.png" /><p>'.(imagesx($image).' x '.imagesy($image)).'</p>'; $image = imagerotate($image,0.1,$bg); imagepng($image,'dump2.png'); echo '<img src="dump2.png" /><p>'.(imagesx($image).' x '.imagesy($image)).'</p>'; ?> ------------------------------------------------------------------------ [2015-07-12 21:30:14] cmb@php.net Related To: Bug #66882 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=65148 -- Edit this bug report at https://bugs.php.net/bug.php?id=65148&edit=1

« previous php.bugs (#212283) next »