-
Notifications
You must be signed in to change notification settings - Fork 677
Description
What happened?
Description
We ran into an issue where our client uploaded an image with the dimensions 1375x793px and we ran that through a transform with mode 'fit'
and width 840
, height is left empty (auto).
The resulting image is 839x484 pixels. This is rendered in a container that expects the image to be 840 wide which result in a blurry image.
The culprit seems to be this line in image/Raster.php:
$factor = max($this->getWidth() / $targetWidth, $this->getHeight() / $targetHeight);
In this case the height factor is slightly higher and takes precedence over the width factor even though the transform rules specify that only the width is important and the height of the resulting image doesn't matter.
Steps to reproduce
- Upload an 1375x793px image to Assets, i.e.: https://dummyimage.com/1375x793
- Set up a transform with mode
fit
, width840
and height empty - Run the transform on the asset
Expected behavior
Get a transformed image with a width of 840px and a height around 484px
Actual behavior
The transformed image has a width of 839px and a height of 484px
Craft CMS version
4.14.3
PHP version
8.2.26
Operating system and version
No response
Database type and version
No response
Image driver and version
No response