Fit::Max resizing images to fill dimensions and painting background #233
rossbearman
started this conversation in
General
Replies: 1 comment 2 replies
-
This should be fixed in the latest release: https://github.com/spatie/image/releases/tag/3.3.7 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The description of
Fit::Max
is:This was the case in v2, but it appears to have changed to instead expand the image if smaller (maintaining the aspect raio), and paint in a background colour if the image doesn't match the aspect ratio of the specified height/width.
If you pass an image with dimensions smaller than 1920x1920 to
->fit(Fit::Max, 1920, 1920)
it will output a 1920x1920 image, with the original image scaled to fit the largest dimension and a white background on the other dimension. This is the behaviour with both the GD and Imagick drivers.In v2 this would output the same size image as the input. The new behaviour is the same as
Manipulations::FIT_FILL_MAX
in v2.The test for
Fit::Max
is titled "can fill and stretch an image in the given dimensions" and the reference test images display the same behaviour, suggesting this is now the intended behaviour, despite it deviating from the behaviour in v2.The Glide implementation used in v2 applies the
upsizing
constraint tomax
, butConstraint::DoNotUpsize
isn't applied inSpatie\Image\Enums\Fit
in v3. Naively applying this constraint in v3 causes the image to not be upscaled, but it still expands the canvas to match whatever dimensions were passed in and paints in a background.(ref spatie/laravel-medialibrary#3518)
Beta Was this translation helpful? Give feedback.
All reactions