From 72f455b2de3e6455a3ded9c6d7116e4fbe883814 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 5 May 2024 13:06:57 +0200 Subject: [PATCH 1/5] Add tests to reproduce bug --- .../Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php | 10 ++++++++++ .../Drivers/Imagick/Modifiers/DrawLineModifierTest.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php b/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php index 67e19f117..903c50eeb 100644 --- a/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php +++ b/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php @@ -25,4 +25,14 @@ public function testApply(): void $image->modify(new DrawLineModifier($line)); $this->assertEquals('b53517', $image->pickColor(0, 0)->toHex()); } + + public function testApplyTransparent(): void + { + $image = $this->createTestImage(10, 10)->fill('ff5500'); + $this->assertColor(255, 85, 0, 255, $image->pickColor(5, 5)); + $line = new Line(new Point(0, 5), new Point(10, 5), 4); + $line->setBackgroundColor('fff4'); + $image->modify(new DrawLineModifier($line)); + $this->assertColor(255, 136, 77, 255, $image->pickColor(5, 5)); + } } diff --git a/tests/Unit/Drivers/Imagick/Modifiers/DrawLineModifierTest.php b/tests/Unit/Drivers/Imagick/Modifiers/DrawLineModifierTest.php index 01762cb92..645c7eedb 100644 --- a/tests/Unit/Drivers/Imagick/Modifiers/DrawLineModifierTest.php +++ b/tests/Unit/Drivers/Imagick/Modifiers/DrawLineModifierTest.php @@ -25,4 +25,14 @@ public function testApply(): void $image->modify(new DrawLineModifier($line)); $this->assertEquals('b53517', $image->pickColor(0, 0)->toHex()); } + + public function testApplyTransparent(): void + { + $image = $this->createTestImage(10, 10)->fill('ff5500'); + $this->assertColor(255, 85, 0, 255, $image->pickColor(5, 5)); + $line = new Line(new Point(0, 5), new Point(10, 5), 4); + $line->setBackgroundColor('fff4'); + $image->modify(new DrawLineModifier($line)); + $this->assertColor(255, 136, 77, 255, $image->pickColor(5, 5)); + } } From 033d12e80713bb6d0298696a01d9321cfdbf612b Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 5 May 2024 13:14:57 +0200 Subject: [PATCH 2/5] Fix bug with unwanted color in DrawLineModifier See: https://github.com/Intervention/image/issues/1347 --- src/Drivers/Imagick/Modifiers/DrawLineModifier.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Drivers/Imagick/Modifiers/DrawLineModifier.php b/src/Drivers/Imagick/Modifiers/DrawLineModifier.php index ca4a04bbe..ac09e51de 100644 --- a/src/Drivers/Imagick/Modifiers/DrawLineModifier.php +++ b/src/Drivers/Imagick/Modifiers/DrawLineModifier.php @@ -19,6 +19,7 @@ public function apply(ImageInterface $image): ImageInterface { $drawing = new ImagickDraw(); $drawing->setStrokeWidth($this->drawable->width()); + $drawing->setFillOpacity(0); $drawing->setStrokeColor( $this->driver()->colorProcessor($image->colorspace())->colorToNative( $this->backgroundColor() From 31fb728c140b29b2f4ab9a99907e9176b68acae1 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 5 May 2024 13:18:03 +0200 Subject: [PATCH 3/5] Fix test --- tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php b/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php index 903c50eeb..85355e538 100644 --- a/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php +++ b/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php @@ -33,6 +33,6 @@ public function testApplyTransparent(): void $line = new Line(new Point(0, 5), new Point(10, 5), 4); $line->setBackgroundColor('fff4'); $image->modify(new DrawLineModifier($line)); - $this->assertColor(255, 136, 77, 255, $image->pickColor(5, 5)); + $this->assertColor(255, 129, 66, 255, $image->pickColor(5, 5)); } } From 93afecd3944bb90800ba6c96e60f22aac8e9c6e1 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 5 May 2024 14:39:29 +0200 Subject: [PATCH 4/5] Add GD version info to github workflow --- .github/workflows/run-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c38966a38..4b98c6729 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -89,7 +89,10 @@ jobs: - name: Install dependencies run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - name: Which Imagick Version + - name: GD Version + run: php -r 'var_dump(gd_info());' + + - name: Imagick Version run: php -r 'var_dump(Imagick::getVersion());' - name: Supported Imagick Formats From 9a013b90fa4af3fe394510b8c80cfbebe7433dd2 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Tue, 7 May 2024 14:43:26 +0200 Subject: [PATCH 5/5] Remove test This test only fails with no longer supported GD lib version 2.1. The docker container of the test environment comes unfortunately with with version and I have not yet managed to install a more recent version. Unfortunately, adding the PHPUnit attribute #RequiresPhpExtension with version number does not work either. --- .../Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php b/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php index 85355e538..67e19f117 100644 --- a/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php +++ b/tests/Unit/Drivers/Gd/Modifiers/DrawLineModifierTest.php @@ -25,14 +25,4 @@ public function testApply(): void $image->modify(new DrawLineModifier($line)); $this->assertEquals('b53517', $image->pickColor(0, 0)->toHex()); } - - public function testApplyTransparent(): void - { - $image = $this->createTestImage(10, 10)->fill('ff5500'); - $this->assertColor(255, 85, 0, 255, $image->pickColor(5, 5)); - $line = new Line(new Point(0, 5), new Point(10, 5), 4); - $line->setBackgroundColor('fff4'); - $image->modify(new DrawLineModifier($line)); - $this->assertColor(255, 129, 66, 255, $image->pickColor(5, 5)); - } }