1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-19 12:11:26 +02:00
This commit is contained in:
Oliver Vogel
2023-12-06 16:11:29 +01:00
parent 38b85fa0f6
commit 8c7fb0cb46
2 changed files with 22 additions and 12 deletions

View File

@@ -47,20 +47,25 @@ class ContainModifier extends DriverSpecializedModifier
// fill new emerged background
$draw = new ImagickDraw();
$draw->setFillColor($background);
if ($crop->pivot()->x() > 0) {
$delta = abs($crop->pivot()->x());
if ($delta > 0) {
$draw->rectangle(
0,
0,
$crop->pivot()->x(),
$delta - 1,
$resize->height()
);
}
$draw->rectangle(
$crop->pivot()->x() + $crop->width(),
$crop->width() + $delta,
0,
$resize->width(),
$resize->height()
);
$frame->native()->drawImage($draw);
}
@@ -68,20 +73,25 @@ class ContainModifier extends DriverSpecializedModifier
// fill new emerged background
$draw = new ImagickDraw();
$draw->setFillColor($background);
if ($crop->pivot()->y() > 0) {
$delta = abs($crop->pivot()->y());
if ($delta > 0) {
$draw->rectangle(
0,
0,
$resize->width(),
$crop->pivot()->y(),
$delta - 1
);
}
$draw->rectangle(
0,
$crop->pivot()->y() + $crop->height(),
$crop->height() + $delta,
$resize->width(),
$resize->height()
);
$frame->native()->drawImage($draw);
}
}

View File

@@ -61,7 +61,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'top-middle':
case 'center-top':
case 'middle-top':
$x = intval($this->width() / 2) + $offset_x;
$x = intval(round($this->width() / 2)) + $offset_x;
$y = 0 + $offset_y;
break;
@@ -77,7 +77,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'center-left':
case 'middle-left':
$x = 0 + $offset_x;
$y = intval($this->height() / 2) + $offset_y;
$y = intval(round($this->height() / 2)) + $offset_y;
break;
case 'right':
@@ -86,7 +86,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'center-right':
case 'middle-right':
$x = $this->width() - $offset_x;
$y = intval($this->height() / 2) + $offset_y;
$y = intval(round($this->height() / 2)) + $offset_y;
break;
case 'bottom-left':
@@ -100,7 +100,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'bottom-middle':
case 'center-bottom':
case 'middle-bottom':
$x = intval($this->width() / 2) + $offset_x;
$x = intval(round($this->width() / 2)) + $offset_x;
$y = $this->height() - $offset_y;
break;
@@ -114,8 +114,8 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'middle':
case 'center-center':
case 'middle-middle':
$x = intval($this->width() / 2) + $offset_x;
$y = intval($this->height() / 2) + $offset_y;
$x = intval(round($this->width() / 2)) + $offset_x;
$y = intval(round($this->height() / 2)) + $offset_y;
break;
default: