summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmb@php.net>2015-07-13 22:14:13 +0200
committerChristoph M. Becker <cmb@php.net>2015-07-13 22:18:56 +0200
commit2e34febb733742baf130a9dae4f30f48ffe74d48 (patch)
tree80c0d508d68f1d2f23e2574704dfb9ce76513cd8
parent72c2fc44e0fb0484ade1ce89da8084dd89714e1c (diff)
downloadphp-git-2e34febb733742baf130a9dae4f30f48ffe74d48.tar.gz
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.
-rw-r--r--ext/gd/libgd/gd_interpolation.c7
-rw-r--r--ext/gd/tests/bug66882.phpt14
2 files changed, 19 insertions, 2 deletions
diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c
index 32d69f9c20..5a3d7f4ee2 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 0000000000..6dfbdfe06d
--- /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)