Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with unwanted color in DrawLineModifer #1348

Merged
merged 5 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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));
}
}