Skip to content

Commit

Permalink
fix(image): Fix Imagemagick resize effect
Browse files Browse the repository at this point in the history
Only apply `^` operator (minimum values of size) if both width and height are supplied, otherwise the image will be cropped to a square.
  • Loading branch information
mcaskill committed Mar 5, 2024
1 parent 116a9ce commit afbbff5
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ protected function doResize($width, $height, $bestFit = false)

$size = $width . 'x' . $height;
if ($bestFit) {
$params[] = $option . ' "' . $size . '^"';
if ($width && $height) {
// Minimum values of width and height given, aspect ratio preserved.
$operator = '^';
} else {
$operator = '';
}

$params[] = $option . ' "' . $size . $operator . '"';
$params[] = '-extent ' . $size;
} else {
$params[] = $option . ' ' . $size;
Expand Down

0 comments on commit afbbff5

Please sign in to comment.