1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-18 19:51:22 +02:00

Fix edge case in CropModifier

This commit is contained in:
Oliver Vogel
2024-01-09 13:30:28 +01:00
parent e93ed68b07
commit c8c5c13acd
2 changed files with 8 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
namespace Intervention\Image\Drivers\Imagick\Modifiers;
use ImagickDraw;
use ImagickPixel;
use Intervention\Image\Drivers\DriverSpecializedModifier;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\SizeInterface;
@@ -23,10 +24,15 @@ class CropModifier extends DriverSpecializedModifier
$this->driver()->handleInput($this->background)
);
$transparent = new ImagickPixel('transparent');
$draw = new ImagickDraw();
$draw->setFillColor($background);
foreach ($image as $frame) {
$frame->native()->setBackgroundColor($transparent);
$frame->native()->setImageBackgroundColor($transparent);
// crop image
$frame->native()->extentImage(
$crop->width(),

View File

@@ -53,10 +53,10 @@ class ImageTest extends TestCase
$this->assertEquals(4, $result->width());
$this->assertEquals('ff0000', $image->pickColor(0, 0)->toHex());
$this->assertEquals('00000000', $image->pickColor(1, 0)->toHex());
$this->assertTransparency($image->pickColor(1, 0));
$this->assertEquals('ff0000', $clone->pickColor(0, 0)->toHex());
$this->assertEquals('00000000', $clone->pickColor(1, 0)->toHex());
$this->assertTransparency($clone->pickColor(1, 0));
}
public function testDriver(): void