Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Aug 13, 2024
1 parent 44d3b85 commit a2cb24c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
17 changes: 9 additions & 8 deletions src/Drivers/Imagick/Modifiers/ResizeCanvasModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,23 @@ public function apply(ImageInterface $image): ImageInterface
$draw = new ImagickDraw();
$draw->setFillColor($background);

$delta = abs($resize->pivot()->x());
$delta_width = abs($resize->pivot()->x());
$delta_height = abs($resize->pivot()->y());

if ($delta > 0) {
if ($delta_width > 0) {
$draw->rectangle(
0,
$delta,
$delta - 1,
$resize->height() - $delta - 1
$delta_height,
$delta_width - 1,
$delta_height + $size->height() - 1
);
}

$draw->rectangle(
$size->width() + $delta,
$delta,
$size->width() + $delta_width,
$delta_height,
$resize->width(),
$resize->height() - $delta - 1
$delta_height + $size->height() - 1
);

$frame->native()->drawImage($draw);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ public function testModifyWithTransparency(): void

$image = $this->createTestImage(16, 16)->fill('f00');
$image->modify(new ResizeCanvasModifier(32, 32, '00f5', 'center'));

$this->assertEquals(32, $image->width());
$this->assertEquals(32, $image->height());
$this->assertColor(0, 0, 255, 77, $image->pickColor(5, 5));
$this->assertColor(0, 0, 255, 77, $image->pickColor(16, 5));
$this->assertColor(0, 0, 255, 77, $image->pickColor(30, 5));

$this->assertColor(0, 0, 255, 77, $image->pickColor(5, 16));
$this->assertColor(255, 0, 0, 255, $image->pickColor(16, 16));
$this->assertColor(0, 0, 255, 77, $image->pickColor(30, 16));

$this->assertColor(0, 0, 255, 77, $image->pickColor(5, 30));
$this->assertColor(0, 0, 255, 77, $image->pickColor(16, 30));
$this->assertColor(0, 0, 255, 77, $image->pickColor(30, 30));
Expand Down

0 comments on commit a2cb24c

Please sign in to comment.