Pārlūkot izejas kodu

fix Image::rotate(): unexpected result for angle == 0 and angle >= 360

Fabian Peter Hammerle 7 gadi atpakaļ
vecāks
revīzija
a2a02f8657
1 mainītis faili ar 7 papildinājumiem un 4 dzēšanām
  1. 7 4
      Image.php

+ 7 - 4
Image.php

@@ -59,14 +59,17 @@ class Image
     }
 
     /**
-     * @param float $angle
+     * @param float $angle anticlockwise
      * @return void
      */
     public function rotate($angle)
     {
-        $resource = imagerotate($this->_resource, $angle, 0);
-        imagedestroy($this->_resource);
-        $this->_resource = $resource;
+        $angle = fmod($angle, 360);
+        if(abs($angle) > 1e-10) {
+            $resource = imagerotate($this->_resource, $angle, 0);
+            imagedestroy($this->_resource);
+            $this->_resource = $resource;
+        }
     }
 
     /**