1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-24 06:22:57 +02:00

Fix ignored opacity in Imagick's PlaceModifer for certain files. (#1346)

* Add tests to reproduce bug in PlaceModifier
* Fix bug in PlaceModifier
* Add tolerance parameter to BaseTestCase::assertColor()
This commit is contained in:
Oliver Vogel
2024-05-05 11:28:01 +02:00
committed by GitHub
parent 1cc333ce73
commit ab403d98c6
4 changed files with 73 additions and 5 deletions

View File

@@ -22,11 +22,19 @@ final class PlaceModifierTest extends GdTestCase
$this->assertEquals('32250d', $image->pickColor(300, 25)->toHex());
}
public function testColorChangeOpacity(): void
public function testColorChangeOpacityPng(): void
{
$image = $this->readTestImage('test.jpg');
$this->assertEquals('febc44', $image->pickColor(300, 25)->toHex());
$image->modify(new PlaceModifier($this->getTestResourcePath('circle.png'), 'top-right', 0, 0, 50));
$this->assertEquals('987028', $image->pickColor(300, 25)->toHex());
}
public function testColorChangeOpacityJpeg(): void
{
$image = $this->createTestImage(16, 16)->fill('0000ff');
$this->assertEquals('0000ff', $image->pickColor(10, 10)->toHex());
$image->modify(new PlaceModifier($this->getTestResourcePath('exif.jpg'), opacity: 50));
$this->assertColor(127, 83, 127, 255, $image->pickColor(10, 10), tolerance: 1);
}
}