Skip to content

Commit afbbff5

Browse files
committed
fix(image): Fix Imagemagick resize effect
Only apply `^` operator (minimum values of size) if both width and height are supplied, otherwise the image will be cropped to a square.
1 parent 116a9ce commit afbbff5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/image/src/Charcoal/Image/Imagemagick/Effect/ImagemagickResizeEffect.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ protected function doResize($width, $height, $bestFit = false)
4949

5050
$size = $width . 'x' . $height;
5151
if ($bestFit) {
52-
$params[] = $option . ' "' . $size . '^"';
52+
if ($width && $height) {
53+
// Minimum values of width and height given, aspect ratio preserved.
54+
$operator = '^';
55+
} else {
56+
$operator = '';
57+
}
58+
59+
$params[] = $option . ' "' . $size . $operator . '"';
5360
$params[] = '-extent ' . $size;
5461
} else {
5562
$params[] = $option . ' ' . $size;

0 commit comments

Comments
 (0)