Skip to content

Commit

Permalink
Add greyscale + missing greyscale test
Browse files Browse the repository at this point in the history
  • Loading branch information
riasvdv committed Jan 17, 2025
1 parent 2e0ae50 commit 2802f14
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Drivers/Vips/VipsDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ public function colorize(int $red, int $green, int $blue): static

public function greyscale(): static
{
// TODO: Implement greyscale() method.
$this->image = $this->image->colourspace('b-w');

return $this;
}

public function sepia(): static
Expand Down
14 changes: 14 additions & 0 deletions tests/Manipulations/GreyscaleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use Spatie\Image\Drivers\ImageDriver;
use Spatie\Image\Exceptions\InvalidManipulation;

use function Spatie\Snapshots\assertMatchesImageSnapshot;

it('can greyscale an image', function (ImageDriver $driver) {
$targetFile = $this->tempDir->path("{$driver->driverName()}/greyscale.png");

$driver->loadFile(getTestJpg())->greyscale()->save($targetFile);

assertMatchesImageSnapshot($targetFile);
})->with('drivers');
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2802f14

Please sign in to comment.