From df4c3e0dddec0ad0e655ead0f8fa66d30c4fd8b1 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Fri, 20 Oct 2023 15:58:35 +0200 Subject: [PATCH] Adjust modifiers for new color model --- .../Rgb/Decoders/TransparentColorDecoder.php | 23 +++++++++++++++++++ .../Modifiers/AbstractDrawModifier.php | 4 ++-- src/Drivers/Gd/InputHandler.php | 3 ++- .../Gd/Modifiers/DrawEllipseModifier.php | 9 +++++--- src/Drivers/Gd/Modifiers/DrawLineModifier.php | 5 +++- .../Gd/Modifiers/DrawPolygonModifier.php | 7 ++++-- .../Gd/Modifiers/DrawRectangleModifier.php | 7 ++++-- src/Drivers/Gd/Modifiers/PadModifier.php | 9 ++++---- src/Drivers/Gd/Modifiers/RotateModifier.php | 5 +++- src/Drivers/Gd/Modifiers/TextWriter.php | 8 +++++-- src/Drivers/Imagick/InputHandler.php | 3 ++- .../Imagick/Modifiers/DrawEllipseModifier.php | 12 ++++++---- .../Imagick/Modifiers/DrawLineModifier.php | 10 +++++--- .../Imagick/Modifiers/DrawPolygonModifier.php | 12 ++++++---- .../Modifiers/DrawRectangleModifier.php | 13 ++++++----- .../Imagick/Modifiers/RotateModifier.php | 8 +++---- tests/Drivers/Gd/InputHandlerTest.php | 15 ++++++------ tests/Drivers/Imagick/InputHandlerTest.php | 9 ++++++++ 18 files changed, 113 insertions(+), 49 deletions(-) create mode 100644 src/Colors/Rgb/Decoders/TransparentColorDecoder.php diff --git a/src/Colors/Rgb/Decoders/TransparentColorDecoder.php b/src/Colors/Rgb/Decoders/TransparentColorDecoder.php new file mode 100644 index 00000000..1474987c --- /dev/null +++ b/src/Colors/Rgb/Decoders/TransparentColorDecoder.php @@ -0,0 +1,23 @@ +drawable; } - protected function getBackgroundColor(): ?ColorInterface + protected function getBackgroundColor(): ColorInterface { try { $color = $this->handleInput($this->drawable->getBackgroundColor()); @@ -42,7 +42,7 @@ class AbstractDrawModifier return $color; } - protected function getBorderColor(): ?ColorInterface + protected function getBorderColor(): ColorInterface { try { $color = $this->handleInput($this->drawable->getBorderColor()); diff --git a/src/Drivers/Gd/InputHandler.php b/src/Drivers/Gd/InputHandler.php index 5069e3fb..85d69a74 100644 --- a/src/Drivers/Gd/InputHandler.php +++ b/src/Drivers/Gd/InputHandler.php @@ -5,6 +5,7 @@ namespace Intervention\Image\Drivers\Gd; use Intervention\Image\Colors\Rgb\Decoders\HexColorDecoder; use Intervention\Image\Colors\Rgb\Decoders\StringColorDecoder; use Intervention\Image\Colors\Rgb\Decoders\HtmlColornameDecoder; +use Intervention\Image\Colors\Rgb\Decoders\TransparentColorDecoder; use Intervention\Image\Drivers\Abstract\AbstractInputHandler; use Intervention\Image\Drivers\Gd\Decoders\ImageObjectDecoder; use Intervention\Image\Drivers\Gd\Decoders\ColorObjectDecoder; @@ -21,7 +22,7 @@ class InputHandler extends AbstractInputHandler ColorObjectDecoder::class, HexColorDecoder::class, StringColorDecoder::class, - // Decoders\TransparentColorDecoder::class, + TransparentColorDecoder::class, HtmlColornameDecoder::class, FilePointerImageDecoder::class, FilePathImageDecoder::class, diff --git a/src/Drivers/Gd/Modifiers/DrawEllipseModifier.php b/src/Drivers/Gd/Modifiers/DrawEllipseModifier.php index 8f956c71..ed99cb3e 100644 --- a/src/Drivers/Gd/Modifiers/DrawEllipseModifier.php +++ b/src/Drivers/Gd/Modifiers/DrawEllipseModifier.php @@ -3,11 +3,14 @@ namespace Intervention\Image\Drivers\Gd\Modifiers; use Intervention\Image\Drivers\Abstract\Modifiers\AbstractDrawModifier; +use Intervention\Image\Drivers\Gd\Traits\CanHandleColors; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; class DrawEllipseModifier extends AbstractDrawModifier implements ModifierInterface { + use CanHandleColors; + public function apply(ImageInterface $image): ImageInterface { return $image->eachFrame(function ($frame) { @@ -20,7 +23,7 @@ class DrawEllipseModifier extends AbstractDrawModifier implements ModifierInterf $this->position->getY(), $this->ellipse()->getWidth() - 1, $this->ellipse()->getHeight() - 1, - $this->getBackgroundColor()->toInt() + $this->colorToInteger($this->getBackgroundColor()) ); } @@ -36,7 +39,7 @@ class DrawEllipseModifier extends AbstractDrawModifier implements ModifierInterf $this->ellipse()->getHeight(), 0, 360, - $this->getBorderColor()->toInt() + $this->colorToInteger($this->getBorderColor()) ); } else { imagefilledellipse( @@ -45,7 +48,7 @@ class DrawEllipseModifier extends AbstractDrawModifier implements ModifierInterf $this->position->getY(), $this->ellipse()->getWidth(), $this->ellipse()->getHeight(), - $this->getBackgroundColor()->toInt() + $this->colorToInteger($this->getBackgroundColor()) ); } }); diff --git a/src/Drivers/Gd/Modifiers/DrawLineModifier.php b/src/Drivers/Gd/Modifiers/DrawLineModifier.php index 677d6345..9cfafb58 100644 --- a/src/Drivers/Gd/Modifiers/DrawLineModifier.php +++ b/src/Drivers/Gd/Modifiers/DrawLineModifier.php @@ -3,11 +3,14 @@ namespace Intervention\Image\Drivers\Gd\Modifiers; use Intervention\Image\Drivers\Abstract\Modifiers\AbstractDrawModifier; +use Intervention\Image\Drivers\Gd\Traits\CanHandleColors; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; class DrawLineModifier extends AbstractDrawModifier implements ModifierInterface { + use CanHandleColors; + public function apply(ImageInterface $image): ImageInterface { return $image->eachFrame(function ($frame) { @@ -17,7 +20,7 @@ class DrawLineModifier extends AbstractDrawModifier implements ModifierInterface $this->line()->getStart()->getY(), $this->line()->getEnd()->getX(), $this->line()->getEnd()->getY(), - $this->getBackgroundColor()->toInt() + $this->colorToInteger($this->getBackgroundColor()) ); }); } diff --git a/src/Drivers/Gd/Modifiers/DrawPolygonModifier.php b/src/Drivers/Gd/Modifiers/DrawPolygonModifier.php index cb4c930f..f0cd77bb 100644 --- a/src/Drivers/Gd/Modifiers/DrawPolygonModifier.php +++ b/src/Drivers/Gd/Modifiers/DrawPolygonModifier.php @@ -3,12 +3,15 @@ namespace Intervention\Image\Drivers\Gd\Modifiers; use Intervention\Image\Drivers\Abstract\Modifiers\AbstractDrawModifier; +use Intervention\Image\Drivers\Gd\Traits\CanHandleColors; use Intervention\Image\Interfaces\DrawableInterface; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; class DrawPolygonModifier extends AbstractDrawModifier implements ModifierInterface { + use CanHandleColors; + public function __construct( protected DrawableInterface $drawable ) { @@ -22,7 +25,7 @@ class DrawPolygonModifier extends AbstractDrawModifier implements ModifierInterf imagefilledpolygon( $frame->getCore(), $this->polygon()->toArray(), - $this->getBackgroundColor()->toInt() + $this->colorToInteger($this->getBackgroundColor()) ); } @@ -32,7 +35,7 @@ class DrawPolygonModifier extends AbstractDrawModifier implements ModifierInterf $frame->getCore(), $this->polygon()->toArray(), $this->polygon()->count(), - $this->getBorderColor()->toInt() + $this->colorToInteger($this->getBorderColor()) ); } }); diff --git a/src/Drivers/Gd/Modifiers/DrawRectangleModifier.php b/src/Drivers/Gd/Modifiers/DrawRectangleModifier.php index 1b5e39dc..2cc1653b 100644 --- a/src/Drivers/Gd/Modifiers/DrawRectangleModifier.php +++ b/src/Drivers/Gd/Modifiers/DrawRectangleModifier.php @@ -3,11 +3,14 @@ namespace Intervention\Image\Drivers\Gd\Modifiers; use Intervention\Image\Drivers\Abstract\Modifiers\AbstractDrawModifier; +use Intervention\Image\Drivers\Gd\Traits\CanHandleColors; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; class DrawRectangleModifier extends AbstractDrawModifier implements ModifierInterface { + use CanHandleColors; + public function apply(ImageInterface $image): ImageInterface { $image->eachFrame(function ($frame) { @@ -19,7 +22,7 @@ class DrawRectangleModifier extends AbstractDrawModifier implements ModifierInte $this->position->getY(), $this->position->getX() + $this->rectangle()->bottomRightPoint()->getX(), $this->position->getY() + $this->rectangle()->bottomRightPoint()->getY(), - $this->getBackgroundColor()->toInt() + $this->colorToInteger($this->getBackgroundColor()) ); } @@ -32,7 +35,7 @@ class DrawRectangleModifier extends AbstractDrawModifier implements ModifierInte $this->position->getY(), $this->position->getX() + $this->rectangle()->bottomRightPoint()->getX(), $this->position->getY() + $this->rectangle()->bottomRightPoint()->getY(), - $this->getBorderColor()->toInt() + $this->colorToInteger($this->getBorderColor()) ); } }); diff --git a/src/Drivers/Gd/Modifiers/PadModifier.php b/src/Drivers/Gd/Modifiers/PadModifier.php index a8e78445..34fdb4d7 100644 --- a/src/Drivers/Gd/Modifiers/PadModifier.php +++ b/src/Drivers/Gd/Modifiers/PadModifier.php @@ -3,7 +3,7 @@ namespace Intervention\Image\Drivers\Gd\Modifiers; use Intervention\Image\Drivers\Abstract\Modifiers\AbstractPadModifier; -use Intervention\Image\Interfaces\ColorInterface; +use Intervention\Image\Drivers\Gd\Traits\CanHandleColors; use Intervention\Image\Interfaces\FrameInterface; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; @@ -13,12 +13,13 @@ use Intervention\Image\Traits\CanHandleInput; class PadModifier extends AbstractPadModifier implements ModifierInterface { use CanHandleInput; + use CanHandleColors; public function apply(ImageInterface $image): ImageInterface { $crop = $this->getCropSize($image); $resize = $this->getResizeSize($image); - $background = $this->handleInput($this->background); + $background = $this->colorToInteger($this->handleInput($this->background)); foreach ($image as $frame) { $this->modify($frame, $crop, $resize, $background); @@ -31,7 +32,7 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface FrameInterface $frame, SizeInterface $crop, SizeInterface $resize, - ColorInterface $background + int $background ): void { // create new image $modified = imagecreatetruecolor( @@ -39,7 +40,7 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface $resize->getHeight() ); - imagefill($modified, 0, 0, $background->toInt()); + imagefill($modified, 0, 0, $background); // get current image $current = $frame->getCore(); diff --git a/src/Drivers/Gd/Modifiers/RotateModifier.php b/src/Drivers/Gd/Modifiers/RotateModifier.php index b692c474..efaecddd 100644 --- a/src/Drivers/Gd/Modifiers/RotateModifier.php +++ b/src/Drivers/Gd/Modifiers/RotateModifier.php @@ -3,11 +3,14 @@ namespace Intervention\Image\Drivers\Gd\Modifiers; use Intervention\Image\Drivers\Abstract\Modifiers\AbstractRotateModifier; +use Intervention\Image\Drivers\Gd\Traits\CanHandleColors; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; class RotateModifier extends AbstractRotateModifier implements ModifierInterface { + use CanHandleColors; + public function apply(ImageInterface $image): ImageInterface { foreach ($image as $frame) { @@ -15,7 +18,7 @@ class RotateModifier extends AbstractRotateModifier implements ModifierInterface imagerotate( $frame->getCore(), $this->rotationAngle(), - $this->backgroundColor()->toInt() + $this->colorToInteger($this->backgroundColor()) ) ); } diff --git a/src/Drivers/Gd/Modifiers/TextWriter.php b/src/Drivers/Gd/Modifiers/TextWriter.php index fd117bca..61cf63ee 100644 --- a/src/Drivers/Gd/Modifiers/TextWriter.php +++ b/src/Drivers/Gd/Modifiers/TextWriter.php @@ -4,14 +4,18 @@ namespace Intervention\Image\Drivers\Gd\Modifiers; use Intervention\Image\Drivers\Abstract\AbstractTextWriter; use Intervention\Image\Drivers\Gd\Font; +use Intervention\Image\Drivers\Gd\Traits\CanHandleColors; use Intervention\Image\Interfaces\ImageInterface; class TextWriter extends AbstractTextWriter { + use CanHandleColors; + public function apply(ImageInterface $image): ImageInterface { $lines = $this->getAlignedTextBlock(); $font = $this->failIfNotClass($this->getFont(), Font::class); + $color = $this->colorToInteger($font->getColor()); foreach ($image as $frame) { if ($this->font->hasFilename()) { @@ -22,7 +26,7 @@ class TextWriter extends AbstractTextWriter $font->getAngle() * (-1), $line->getPosition()->getX(), $line->getPosition()->getY(), - $font->getColor()->toInt(), + $color, $font->getFilename(), $line ); @@ -35,7 +39,7 @@ class TextWriter extends AbstractTextWriter $line->getPosition()->getX(), $line->getPosition()->getY(), $line, - $this->font->getColor()->toInt() + $color ); } } diff --git a/src/Drivers/Imagick/InputHandler.php b/src/Drivers/Imagick/InputHandler.php index 27ca7c5b..3d27678a 100644 --- a/src/Drivers/Imagick/InputHandler.php +++ b/src/Drivers/Imagick/InputHandler.php @@ -5,6 +5,7 @@ namespace Intervention\Image\Drivers\Imagick; use Intervention\Image\Colors\Rgb\Decoders\HexColorDecoder; use Intervention\Image\Colors\Rgb\Decoders\StringColorDecoder; use Intervention\Image\Colors\Rgb\Decoders\HtmlColornameDecoder; +use Intervention\Image\Colors\Rgb\Decoders\TransparentColorDecoder; use Intervention\Image\Drivers\Abstract\AbstractInputHandler; use Intervention\Image\Drivers\Imagick\Decoders\ImageObjectDecoder; use Intervention\Image\Drivers\Imagick\Decoders\ColorObjectDecoder; @@ -21,7 +22,7 @@ class InputHandler extends AbstractInputHandler ColorObjectDecoder::class, HexColorDecoder::class, StringColorDecoder::class, - // Decoders\TransparentColorDecoder::class, + TransparentColorDecoder::class, HtmlColornameDecoder::class, FilePointerImageDecoder::class, FilePathImageDecoder::class, diff --git a/src/Drivers/Imagick/Modifiers/DrawEllipseModifier.php b/src/Drivers/Imagick/Modifiers/DrawEllipseModifier.php index 289500c2..0c3e53fc 100644 --- a/src/Drivers/Imagick/Modifiers/DrawEllipseModifier.php +++ b/src/Drivers/Imagick/Modifiers/DrawEllipseModifier.php @@ -4,24 +4,26 @@ namespace Intervention\Image\Drivers\Imagick\Modifiers; use ImagickDraw; use Intervention\Image\Drivers\Abstract\Modifiers\AbstractDrawModifier; -use Intervention\Image\Drivers\Imagick\Color; +use Intervention\Image\Drivers\Imagick\Traits\CanHandleColors; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; class DrawEllipseModifier extends AbstractDrawModifier implements ModifierInterface { + use CanHandleColors; + public function apply(ImageInterface $image): ImageInterface { - $background_color = $this->failIfNotClass($this->getBackgroundColor(), Color::class); - $border_color = $this->failIfNotClass($this->getBorderColor(), Color::class); + $background_color = $this->colorToPixel($this->getBackgroundColor()); + $border_color = $this->colorToPixel($this->getBorderColor()); return $image->eachFrame(function ($frame) use ($background_color, $border_color) { $drawing = new ImagickDraw(); - $drawing->setFillColor($background_color->getPixel()); + $drawing->setFillColor($background_color); if ($this->ellipse()->hasBorder()) { $drawing->setStrokeWidth($this->ellipse()->getBorderSize()); - $drawing->setStrokeColor($border_color->getPixel()); + $drawing->setStrokeColor($border_color); } $drawing->ellipse( diff --git a/src/Drivers/Imagick/Modifiers/DrawLineModifier.php b/src/Drivers/Imagick/Modifiers/DrawLineModifier.php index 17c4ac76..74fa9472 100644 --- a/src/Drivers/Imagick/Modifiers/DrawLineModifier.php +++ b/src/Drivers/Imagick/Modifiers/DrawLineModifier.php @@ -4,18 +4,22 @@ namespace Intervention\Image\Drivers\Imagick\Modifiers; use ImagickDraw; use Intervention\Image\Drivers\Abstract\Modifiers\AbstractDrawModifier; -use Intervention\Image\Drivers\Imagick\Color; +use Intervention\Image\Drivers\Imagick\Traits\CanHandleColors; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; class DrawLineModifier extends AbstractDrawModifier implements ModifierInterface { + use CanHandleColors; + public function apply(ImageInterface $image): ImageInterface { $drawing = new ImagickDraw(); - $color = $this->failIfNotClass($this->getBackgroundColor(), Color::class); - $drawing->setStrokeColor($color->getPixel()); $drawing->setStrokeWidth($this->line()->getWidth()); + $drawing->setStrokeColor( + $this->colorToPixel($this->getBackgroundColor()) + ); + $drawing->line( $this->line()->getStart()->getX(), $this->line()->getStart()->getY(), diff --git a/src/Drivers/Imagick/Modifiers/DrawPolygonModifier.php b/src/Drivers/Imagick/Modifiers/DrawPolygonModifier.php index ea8b511c..34634dbb 100644 --- a/src/Drivers/Imagick/Modifiers/DrawPolygonModifier.php +++ b/src/Drivers/Imagick/Modifiers/DrawPolygonModifier.php @@ -4,13 +4,15 @@ namespace Intervention\Image\Drivers\Imagick\Modifiers; use ImagickDraw; use Intervention\Image\Drivers\Abstract\Modifiers\AbstractDrawModifier; -use Intervention\Image\Drivers\Imagick\Color; +use Intervention\Image\Drivers\Imagick\Traits\CanHandleColors; use Intervention\Image\Interfaces\DrawableInterface; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; class DrawPolygonModifier extends AbstractDrawModifier implements ModifierInterface { + use CanHandleColors; + public function __construct( protected DrawableInterface $drawable ) { @@ -20,15 +22,15 @@ class DrawPolygonModifier extends AbstractDrawModifier implements ModifierInterf public function apply(ImageInterface $image): ImageInterface { $drawing = new ImagickDraw(); - $background_color = $this->failIfNotClass($this->getBackgroundColor(), Color::class); - $border_color = $this->failIfNotClass($this->getBorderColor(), Color::class); + $background_color = $this->colorToPixel($this->getBackgroundColor()); + $border_color = $this->colorToPixel($this->getBorderColor()); if ($this->polygon()->hasBackgroundColor()) { - $drawing->setFillColor($background_color->getPixel()); + $drawing->setFillColor($background_color); } if ($this->polygon()->hasBorder()) { - $drawing->setStrokeColor($border_color->getPixel()); + $drawing->setStrokeColor($border_color); $drawing->setStrokeWidth($this->polygon()->getBorderSize()); } diff --git a/src/Drivers/Imagick/Modifiers/DrawRectangleModifier.php b/src/Drivers/Imagick/Modifiers/DrawRectangleModifier.php index 2baf9721..60d225d3 100644 --- a/src/Drivers/Imagick/Modifiers/DrawRectangleModifier.php +++ b/src/Drivers/Imagick/Modifiers/DrawRectangleModifier.php @@ -4,22 +4,23 @@ namespace Intervention\Image\Drivers\Imagick\Modifiers; use ImagickDraw; use Intervention\Image\Drivers\Abstract\Modifiers\AbstractDrawModifier; -use Intervention\Image\Drivers\Imagick\Color; +use Intervention\Image\Drivers\Imagick\Traits\CanHandleColors; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; class DrawRectangleModifier extends AbstractDrawModifier implements ModifierInterface { + use CanHandleColors; + public function apply(ImageInterface $image): ImageInterface { - // setup $drawing = new ImagickDraw(); - $background_color = $this->failIfNotClass($this->getBackgroundColor(), Color::class); - $border_color = $this->failIfNotClass($this->getBorderColor(), Color::class); + $background_color = $this->colorToPixel($this->getBackgroundColor()); + $border_color = $this->colorToPixel($this->getBorderColor()); - $drawing->setFillColor($background_color->getPixel()); + $drawing->setFillColor($background_color); if ($this->rectangle()->hasBorder()) { - $drawing->setStrokeColor($border_color->getPixel()); + $drawing->setStrokeColor($border_color); $drawing->setStrokeWidth($this->rectangle()->getBorderSize()); } diff --git a/src/Drivers/Imagick/Modifiers/RotateModifier.php b/src/Drivers/Imagick/Modifiers/RotateModifier.php index ff908c04..e178f31c 100644 --- a/src/Drivers/Imagick/Modifiers/RotateModifier.php +++ b/src/Drivers/Imagick/Modifiers/RotateModifier.php @@ -3,19 +3,19 @@ namespace Intervention\Image\Drivers\Imagick\Modifiers; use Intervention\Image\Drivers\Abstract\Modifiers\AbstractRotateModifier; -use Intervention\Image\Drivers\Imagick\Color; +use Intervention\Image\Drivers\Imagick\Traits\CanHandleColors; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; class RotateModifier extends AbstractRotateModifier implements ModifierInterface { + use CanHandleColors; + public function apply(ImageInterface $image): ImageInterface { - $background = $this->failIfNotClass($this->backgroundColor(), Color::class); - foreach ($image as $frame) { $frame->getCore()->rotateImage( - $background->getPixel(), + $this->colorToPixel($this->backgroundColor()), $this->rotationAngle() ); } diff --git a/tests/Drivers/Gd/InputHandlerTest.php b/tests/Drivers/Gd/InputHandlerTest.php index 7be7f4e0..c9d1335b 100644 --- a/tests/Drivers/Gd/InputHandlerTest.php +++ b/tests/Drivers/Gd/InputHandlerTest.php @@ -105,11 +105,12 @@ class GdInputHandlerTest extends TestCase $this->assertEquals([10, 20, 30, 255], $result->toArray()); } - // public function testHandleTransparent(): void - // { - // $handler = new InputHandler(); - // $input = 'transparent'; - // $result = $handler->handle($input); - // $this->assertInstanceOf(Color::class, $result); - // } + public function testHandleTransparent(): void + { + $handler = new InputHandler(); + $input = 'transparent'; + $result = $handler->handle($input); + $this->assertInstanceOf(Color::class, $result); + $this->assertEquals([0, 0, 0, 0], $result->toArray()); + } } diff --git a/tests/Drivers/Imagick/InputHandlerTest.php b/tests/Drivers/Imagick/InputHandlerTest.php index df2a5b1a..ed7a99ca 100644 --- a/tests/Drivers/Imagick/InputHandlerTest.php +++ b/tests/Drivers/Imagick/InputHandlerTest.php @@ -104,4 +104,13 @@ class InputHandlerTest extends TestCase $this->assertInstanceOf(Color::class, $result); $this->assertEquals([10, 20, 30, 255], $result->toArray()); } + + public function testHandleTransparent(): void + { + $handler = new InputHandler(); + $input = 'transparent'; + $result = $handler->handle($input); + $this->assertInstanceOf(Color::class, $result); + $this->assertEquals([0, 0, 0, 0], $result->toArray()); + } }