com php-src: Fix #66882: imagerotate by -90 degrees truncates image by 1px: ext/gd/libgd/gd_interpolation.c ext/gd/tests/bug668 82.phpt
| From: | Christoph Michael Becker | Date: | Mon, 13 Jul 2015 20:14:13 +0000 |
| Subject: | com php-src: Fix #66882: imagerotate by -90 degrees truncates image by 1px: ext/gd/libgd/gd_interpolation.c ext/gd/tests/bug668 82.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87984@lists.php.net to get a copy of this message | ||
Commit: 36439cf7b8b00249f8f90be9dabe1e24bbadf7a1
Author: Christoph M. Becker <cmb@php.net> Mon, 13 Jul 2015 22:14:13 +0200
Parents: 2a2d3e88e6722d9277097d8e6a39f2e40a8befb9
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=36439cf7b8b00249f8f90be9dabe1e24bbadf7a1
Log:
Fix #66882: imagerotate by -90 degrees truncates image by 1px
Contrary to the external libgd, the bundled libgd doesn't use optimized
rotation algorithms for negative square angles.. We fix that now.
There are other improvements in gdImageRotateInterpolated() in the external
libgd. I'll leave them out for now, in the hope that we'll be able to rejoin
the two libraries rather soon.
Bugs:
https://bugs.php.net/66882
Changed paths:
M ext/gd/libgd/gd_interpolation.c
A ext/gd/tests/bug66882.phpt
Diff:
diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c
index e2c9f05..94c4968 100644
--- a/ext/gd/libgd/gd_interpolation.c
+++ b/ext/gd/libgd/gd_interpolation.c
@@ -2178,10 +2178,13 @@ gdImagePtr gdImageRotateInterpolated(const gdImagePtr src, const float
angle, in
/* no interpolation needed here */
switch (angle_rounded) {
- case 9000:
+ case -27000:
+ case 9000:
return gdImageRotate90(src, 0);
- case 18000:
+ case -18000:
+ case 18000:
return gdImageRotate180(src, 0);
+ case -9000:
case 27000:
return gdImageRotate270(src, 0);
}
diff --git a/ext/gd/tests/bug66882.phpt b/ext/gd/tests/bug66882.phpt
new file mode 100644
index 0000000..6dfbdfe
--- /dev/null
+++ b/ext/gd/tests/bug66882.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #66882 (imagerotate by -90 degrees truncates image by 1px)
+--SKIPIF--
+<?php
+if (!extension_loaded('gd')) die('skip gd extension not available');
+?>
+--FILE--
+<?php
+$im = imagerotate(imagecreate(10, 10), -90, 0);
+var_dump(imagesy($im), imagesx($im));
+?>
+--EXPECT--
+int(10)
+int(10)