diff --git a/src/ImageMagickAdapter.php b/src/ImageMagickAdapter.php index a244ebc..b0499bf 100644 --- a/src/ImageMagickAdapter.php +++ b/src/ImageMagickAdapter.php @@ -88,10 +88,14 @@ public function crop($width, $height) if ($width == 0) $width = $height; if ($height == 0) $height = $width; + $size = $width . 'x' . $height; + + $this->args[] = '-resize'; + $this->args[] = "$size^"; $this->args[] = '-gravity'; $this->args[] = 'center'; $this->args[] = '-crop'; - $this->args[] = $width . 'x' . $height . '+0+0'; + $this->args[] = "$size+0+0"; $this->args[] = '+repage'; return $this; } diff --git a/tests/BaseAdapterTest.php b/tests/BaseAdapterTest.php index ffdbf60..1bb27a8 100644 --- a/tests/BaseAdapterTest.php +++ b/tests/BaseAdapterTest.php @@ -63,10 +63,10 @@ public function testCrop() $this->assertSize($orig, 1000, 500); ($this->getAdapter($orig)) - ->crop(500, 500) + ->crop(250, 250) ->save($dest); - $this->assertSize($dest, 500, 500); + $this->assertSize($dest, 250, 250); $this->assertColor($dest, 'top', 'blue'); $this->assertColor($dest, 'bottom', 'green'); $this->assertAlpha($dest, 'center', 100);