diff --git a/src/Drivers/Abstract/AbstractImage.php b/src/Drivers/Abstract/AbstractImage.php index 55c3be56..2b1b4d6a 100644 --- a/src/Drivers/Abstract/AbstractImage.php +++ b/src/Drivers/Abstract/AbstractImage.php @@ -139,6 +139,13 @@ abstract class AbstractImage ); } + public function gamma(float $gamma): ImageInterface + { + return $this->modify( + $this->resolveDriverClass('Modifiers\GammaModifier', $gamma) + ); + } + public function blur(int $amount = 5): ImageInterface { return $this->modify( diff --git a/src/Drivers/Gd/Modifiers/GammaModifier.php b/src/Drivers/Gd/Modifiers/GammaModifier.php new file mode 100644 index 00000000..f9208739 --- /dev/null +++ b/src/Drivers/Gd/Modifiers/GammaModifier.php @@ -0,0 +1,23 @@ +getCore(), 1, $this->gamma); + } + + return $image; + } +} diff --git a/src/Drivers/Imagick/Modifiers/GammaModifier.php b/src/Drivers/Imagick/Modifiers/GammaModifier.php new file mode 100644 index 00000000..ad813ace --- /dev/null +++ b/src/Drivers/Imagick/Modifiers/GammaModifier.php @@ -0,0 +1,23 @@ +getCore()->gammaImage($this->gamma); + } + + return $image; + } +} diff --git a/tests/Drivers/Gd/Modifiers/GammaModifierTest.php b/tests/Drivers/Gd/Modifiers/GammaModifierTest.php new file mode 100644 index 00000000..dec4de93 --- /dev/null +++ b/tests/Drivers/Gd/Modifiers/GammaModifierTest.php @@ -0,0 +1,24 @@ +createTestImage('trim.png'); + $this->assertEquals('00aef0', $image->pickColor(0, 0)->toHex()); + $image->modify(new GammaModifier(2.1)); + $this->assertEquals('00d5f8', $image->pickColor(0, 0)->toHex()); + } +} diff --git a/tests/Drivers/Imagick/Modifiers/GammaModifierTest.php b/tests/Drivers/Imagick/Modifiers/GammaModifierTest.php new file mode 100644 index 00000000..c3af78c0 --- /dev/null +++ b/tests/Drivers/Imagick/Modifiers/GammaModifierTest.php @@ -0,0 +1,24 @@ +createTestImage('trim.png'); + $this->assertEquals('00aef0', $image->pickColor(0, 0)->toHex()); + $image->modify(new GammaModifier(2.1)); + $this->assertEquals('00d5f8', $image->pickColor(0, 0)->toHex()); + } +}