From 56a064d8679e83106a72ab4ef84c399d54bc1f2b Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sat, 27 Jan 2024 11:07:06 +0100 Subject: [PATCH] Add tests for Image::blendTransparency() --- tests/Drivers/Gd/ImageTest.php | 9 +++++++++ tests/Drivers/Imagick/ImageTest.php | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/tests/Drivers/Gd/ImageTest.php b/tests/Drivers/Gd/ImageTest.php index fc64489c..fd4bc6eb 100644 --- a/tests/Drivers/Gd/ImageTest.php +++ b/tests/Drivers/Gd/ImageTest.php @@ -276,6 +276,15 @@ class ImageTest extends TestCase $this->assertColor(1, 2, 3, 4, $image->blendingColor()); } + public function testBlendTransparency(): void + { + $image = $this->readTestImage('gradient.gif'); + $this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0)); + $result = $image->blendTransparency('ff5500'); + $this->assertColor(255, 85, 0, 255, $image->pickColor(1, 0)); + $this->assertColor(255, 85, 0, 255, $result->pickColor(1, 0)); + } + public function testToJpeg(): void { $this->assertMediaType('image/jpeg', (string) $this->image->toJpeg()); diff --git a/tests/Drivers/Imagick/ImageTest.php b/tests/Drivers/Imagick/ImageTest.php index 55a85ca6..b121779f 100644 --- a/tests/Drivers/Imagick/ImageTest.php +++ b/tests/Drivers/Imagick/ImageTest.php @@ -269,6 +269,15 @@ class ImageTest extends TestCase $this->assertColor(1, 2, 3, 4, $image->blendingColor()); } + public function testBlendTransparency(): void + { + $image = $this->readTestImage('gradient.gif'); + $this->assertColor(0, 0, 0, 0, $image->pickColor(1, 0)); + $result = $image->blendTransparency('ff5500'); + $this->assertColor(255, 85, 0, 255, $image->pickColor(1, 0)); + $this->assertColor(255, 85, 0, 255, $result->pickColor(1, 0)); + } + public function testToJpeg(): void { $this->assertMediaType('image/jpeg', (string) $this->image->toJpeg());