1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-20 04:31:24 +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 // fill new emerged background
$draw = new ImagickDraw(); $draw = new ImagickDraw();
$draw->setFillColor($background); $draw->setFillColor($background);
if ($crop->pivot()->x() > 0) {
$delta = abs($crop->pivot()->x());
if ($delta > 0) {
$draw->rectangle( $draw->rectangle(
0, 0,
0, 0,
$crop->pivot()->x(), $delta - 1,
$resize->height() $resize->height()
); );
} }
$draw->rectangle( $draw->rectangle(
$crop->pivot()->x() + $crop->width(), $crop->width() + $delta,
0, 0,
$resize->width(), $resize->width(),
$resize->height() $resize->height()
); );
$frame->native()->drawImage($draw); $frame->native()->drawImage($draw);
} }
@@ -68,20 +73,25 @@ class ContainModifier extends DriverSpecializedModifier
// fill new emerged background // fill new emerged background
$draw = new ImagickDraw(); $draw = new ImagickDraw();
$draw->setFillColor($background); $draw->setFillColor($background);
if ($crop->pivot()->y() > 0) {
$delta = abs($crop->pivot()->y());
if ($delta > 0) {
$draw->rectangle( $draw->rectangle(
0, 0,
0, 0,
$resize->width(), $resize->width(),
$crop->pivot()->y(), $delta - 1
); );
} }
$draw->rectangle( $draw->rectangle(
0, 0,
$crop->pivot()->y() + $crop->height(), $crop->height() + $delta,
$resize->width(), $resize->width(),
$resize->height() $resize->height()
); );
$frame->native()->drawImage($draw); $frame->native()->drawImage($draw);
} }
} }

View File

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