Skip to content

Commit

Permalink
Fix edge case in CropModifier
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Jan 9, 2024
1 parent e93ed68 commit c8c5c13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Drivers/Imagick/Modifiers/CropModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,10 +24,15 @@ public function apply(ImageInterface $image): ImageInterface
$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(),
Expand Down
4 changes: 2 additions & 2 deletions tests/Drivers/Imagick/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public function testClone(): void
$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
Expand Down

0 comments on commit c8c5c13

Please sign in to comment.