diff --git a/src/Drivers/Imagick/ImagickDriver.php b/src/Drivers/Imagick/ImagickDriver.php index 75409036..003397df 100644 --- a/src/Drivers/Imagick/ImagickDriver.php +++ b/src/Drivers/Imagick/ImagickDriver.php @@ -470,6 +470,10 @@ public function flip(FlipDirection $flip): static public function pixelate(int $pixelate = 50): static { + if ($pixelate === 0) { + return $this; + } + $width = $this->getWidth(); $height = $this->getHeight(); diff --git a/tests/Manipulations/BlurTest.php b/tests/Manipulations/BlurTest.php index ed8939e5..8b16e25c 100644 --- a/tests/Manipulations/BlurTest.php +++ b/tests/Manipulations/BlurTest.php @@ -5,13 +5,13 @@ use function Spatie\Snapshots\assertMatchesImageSnapshot; -it('can blur an image', function (ImageDriver $driver) { +it('can blur an image', function (ImageDriver $driver, int $blur) { $targetFile = $this->tempDir->path("{$driver->driverName()}/blur.png"); - $driver->loadFile(getTestJpg())->blur(50)->save($targetFile); + $driver->loadFile(getTestJpg())->blur($blur)->save($targetFile); assertMatchesImageSnapshot($targetFile); -})->with('drivers'); +})->with('drivers', [0, 50, 100]); it('will throw an exception when passing an invalid blur value', function (ImageDriver $driver) { $driver->loadFile(getTestJpg())->blur(101); diff --git a/tests/Manipulations/PixelateTest.php b/tests/Manipulations/PixelateTest.php index ec5e5538..e023f22b 100644 --- a/tests/Manipulations/PixelateTest.php +++ b/tests/Manipulations/PixelateTest.php @@ -1,13 +1,18 @@ tempDir->path("{$driver->driverName()}/pixelate.png"); - $driver->loadFile(getTestJpg())->pixelate()->save($targetFile); + $driver->loadFile(getTestJpg())->pixelate($pixelate)->save($targetFile); assertMatchesImageSnapshot($targetFile); -})->with('drivers'); +})->with('drivers', [0, 50, 100]); + +it('will throw an exception when passing an invalid pixelate value', function (ImageDriver $driver) { + $driver->loadFile(getTestJpg())->pixelate(101); +})->with('drivers')->throws(InvalidManipulation::class); diff --git a/tests/Manipulations/SharpenTest.php b/tests/Manipulations/SharpenTest.php index 012dc306..57aafbd0 100644 --- a/tests/Manipulations/SharpenTest.php +++ b/tests/Manipulations/SharpenTest.php @@ -5,13 +5,13 @@ use function Spatie\Snapshots\assertMatchesImageSnapshot; -it('can sharpen an image', function (ImageDriver $driver) { +it('can sharpen an image', function (ImageDriver $driver, int $sharpen) { $targetFile = $this->tempDir->path("{$driver->driverName()}/sharpen.png"); - $driver->loadFile(getTestJpg())->sharpen(50)->save($targetFile); + $driver->loadFile(getTestJpg())->sharpen($sharpen)->save($targetFile); assertMatchesImageSnapshot($targetFile); -})->with('drivers'); +})->with('drivers', [0, 50, 100]); it('will throw an exception when passing an invalid sharpen value', function (ImageDriver $driver) { $driver->loadFile(getTestJpg())->sharpen(101);