Bug with resize configuration
Toflar opened this issue · 5 comments
When my image is too small to be resized, I thought contao/image
is not supposed to touch it.
This is the case when I use this code:
$resizeConfig = new ResizeConfiguration();
$resizeConfig->setWidth($width)->setHeight($height)->setMode(ResizeConfiguration::MODE_PROPORTIONAL);
$image = $this->imageFactory->create($absolutePath, $resizeConfig);
However, if I do not set any mode (so the default one CROP
is used), like so:
$resizeConfig = new ResizeConfiguration();
$resizeConfig->setWidth($width)->setHeight($height);
$image = $this->imageFactory->create($absolutePath, $resizeConfig);
I get a cropped version anyway. Is that intended? Even if my $width
and $height
are both smaller than what I set on the ResizeConfiguration
?
Could this be the explanation for contao/core-bundle#817 as well?
If the ratio of your $width/$height
is different than the ratio of the original image, the behavior is correct.
I do not think that it’s related to contao/core-bundle#817.
IMO it does. If you tell the library that you want a square thumbnail with 100x100 for example, but the size of the image is only 200x80, the result would be a square 80x80 thumbnail, which is correct IMO.
This is also required for images in the srcset
attribute, they must have the same aspect ratio and show the same contents, independent from their size.
Sounds reasonable to me. Thanks for the clarification.