Skip to content

Commit

Permalink
add colorize operation
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jan 27, 2025
1 parent 62fc8a1 commit 25dee39
Showing 2 changed files with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Drivers/Vips/VipsDriver.php
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

namespace Spatie\Image\Drivers\Vips;

use Jcupitt\Vips\BandFormat;
use Jcupitt\Vips\Exception;
use Jcupitt\Vips\Image;
use Spatie\Image\Drivers\Concerns\AddsWatermark;
@@ -142,7 +143,13 @@ public function blur(int $blur): static

public function colorize(int $red, int $green, int $blue): static
{
// TODO: Implement colorize() method.
$overlay = Image::black($this->image->width, $this->image->height)
->add([$red, $green, $blue])
->cast(BandFormat::UCHAR);

$this->image = $this->image->composite2($overlay, 'add');

return $this;
}

public function greyscale(): static
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 25dee39

Please sign in to comment.