Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function apply(ImageInterface $image): ImageInterface
try {
$frame->native()->setImageBackgroundColor($pixel);
$frame->native()->setImageAlphaChannel(Imagick::ALPHACHANNEL_REMOVE);
$frame->setNative($frame->native()->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN));
} catch (ImagickException $e) {
throw new ModifierException(
'Failed to apply ' . self::class . ', unable to set image background color',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Intervention\Image\Tests\Unit\Drivers\Imagick\Modifiers;

use Intervention\Image\Colors\Rgb\Color;
use Intervention\Image\Modifiers\FillTransparentAreasModifier;
use Intervention\Image\Tests\ImagickTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;

#[RequiresPhpExtension('imagick')]
#[CoversClass(\Intervention\Image\Modifiers\FillTransparentAreasModifier::class)]
#[CoversClass(\Intervention\Image\Drivers\Imagick\Modifiers\FillTransparentAreasModifier::class)]
final class FillTransparentAreasModifierTest extends ImagickTestCase
{
public function testFillTransparentAreas(): void
{
$image = $this->readTestImage('circle.png');
$this->assertTransparency($image->colorAt(0, 0));
$image->modify(new FillTransparentAreasModifier(new Color(255, 85, 0)));
$this->assertColor(255, 85, 0, 255, $image->colorAt(0, 0));
}

public function testFillTransparentAreasKeepsAnimationFrames(): void
{
$image = $this->readTestImage('animation.gif');
$count = count($image);
$this->assertGreaterThan(1, $count);
$image->modify(new FillTransparentAreasModifier(new Color(255, 85, 0)));
$this->assertCount($count, $image);
}
}