Skip to content

Commit

Permalink
Merge pull request #1348 from Intervention/bugfix/draw-line-modifier
Browse files Browse the repository at this point in the history
Fix bug with unwanted color in DrawLineModifer
  • Loading branch information
olivervogel committed May 7, 2024
2 parents 2e0cbf2 + 9a013b9 commit 7f33feb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/run-tests.yml
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/Drivers/Imagick/Modifiers/DrawLineModifier.php
Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions tests/Unit/Drivers/Imagick/Modifiers/DrawLineModifierTest.php
Expand Up @@ -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));
}
}

0 comments on commit 7f33feb

Please sign in to comment.