Skip to content

Commit 01009ae

Browse files
javiermarinrosjavimarinros
andauthored
Remove discarded flatten in fillTransparentAreas (#1561)
Co-authored-by: javimarinros <contacto@ideatic.net>
1 parent 4cb9b70 commit 01009ae

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

‎src/Drivers/Imagick/Modifiers/FillTransparentAreasModifier.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public function apply(ImageInterface $image): ImageInterface
3232
try {
3333
$frame->native()->setImageBackgroundColor($pixel);
3434
$frame->native()->setImageAlphaChannel(Imagick::ALPHACHANNEL_REMOVE);
35-
$frame->setNative($frame->native()->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN));
3635
} catch (ImagickException $e) {
3736
throw new ModifierException(
3837
'Failed to apply ' . self::class . ', unable to set image background color',
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Intervention\Image\Tests\Unit\Drivers\Imagick\Modifiers;
6+
7+
use Intervention\Image\Colors\Rgb\Color;
8+
use Intervention\Image\Modifiers\FillTransparentAreasModifier;
9+
use Intervention\Image\Tests\ImagickTestCase;
10+
use PHPUnit\Framework\Attributes\CoversClass;
11+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
12+
13+
#[RequiresPhpExtension('imagick')]
14+
#[CoversClass(\Intervention\Image\Modifiers\FillTransparentAreasModifier::class)]
15+
#[CoversClass(\Intervention\Image\Drivers\Imagick\Modifiers\FillTransparentAreasModifier::class)]
16+
final class FillTransparentAreasModifierTest extends ImagickTestCase
17+
{
18+
public function testFillTransparentAreas(): void
19+
{
20+
$image = $this->readTestImage('circle.png');
21+
$this->assertTransparency($image->colorAt(0, 0));
22+
$image->modify(new FillTransparentAreasModifier(new Color(255, 85, 0)));
23+
$this->assertColor(255, 85, 0, 255, $image->colorAt(0, 0));
24+
}
25+
26+
public function testFillTransparentAreasKeepsAnimationFrames(): void
27+
{
28+
$image = $this->readTestImage('animation.gif');
29+
$count = count($image);
30+
$this->assertGreaterThan(1, $count);
31+
$image->modify(new FillTransparentAreasModifier(new Color(255, 85, 0)));
32+
$this->assertCount($count, $image);
33+
}
34+
}

0 commit comments

Comments
 (0)