mirror of
https://github.com/Intervention/image.git
synced 2025-08-19 12:11:26 +02:00
Fix bugs
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user