mirror of
https://github.com/Intervention/image.git
synced 2025-08-30 09:10:21 +02:00
Merge pull request #833 from lboynton/restrict-max-rotation-value
Restrict the maximum rotation value to 360 degrees
This commit is contained in:
@@ -18,6 +18,9 @@ class RotateCommand extends \Intervention\Image\Commands\AbstractCommand
|
|||||||
$color = $this->argument(1)->value();
|
$color = $this->argument(1)->value();
|
||||||
$color = new Color($color);
|
$color = new Color($color);
|
||||||
|
|
||||||
|
// restrict rotations beyond 360 degrees, since the end result is the same
|
||||||
|
$angle %= 360;
|
||||||
|
|
||||||
// rotate image
|
// rotate image
|
||||||
$image->setCore(imagerotate($image->getCore(), $angle, $color->getInt()));
|
$image->setCore(imagerotate($image->getCore(), $angle, $color->getInt()));
|
||||||
|
|
||||||
|
@@ -18,6 +18,9 @@ class RotateCommand extends \Intervention\Image\Commands\AbstractCommand
|
|||||||
$color = $this->argument(1)->value();
|
$color = $this->argument(1)->value();
|
||||||
$color = new Color($color);
|
$color = new Color($color);
|
||||||
|
|
||||||
|
// restrict rotations beyond 360 degrees, since the end result is the same
|
||||||
|
$angle %= 360;
|
||||||
|
|
||||||
// rotate image
|
// rotate image
|
||||||
$image->getCore()->rotateImage($color->getPixel(), ($angle * -1));
|
$image->getCore()->rotateImage($color->getPixel(), ($angle * -1));
|
||||||
|
|
||||||
|
@@ -32,4 +32,16 @@ class RotateCommandTest extends PHPUnit_Framework_TestCase
|
|||||||
$result = $command->execute($image);
|
$result = $command->execute($image);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImagickWithLargeRotation()
|
||||||
|
{
|
||||||
|
$rotation = 45;
|
||||||
|
$imagick = Mockery::mock('Imagick');
|
||||||
|
$imagick->shouldReceive('rotateimage')->with(Mockery::type('object'), -$rotation)->andReturn(true);
|
||||||
|
$image = Mockery::mock('Intervention\Image\Image');
|
||||||
|
$image->shouldReceive('getCore')->once()->andReturn($imagick);
|
||||||
|
$command = new RotateImagick([$rotation + (360 * 1000), '#b53717']);
|
||||||
|
$result = $command->execute($image);
|
||||||
|
$this->assertTrue($result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user