thephpleague / glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.
http://glide.thephpleague.com
MIT License
2.55k stars 198 forks source link

Fix rounding issue with Manipulators\Size #310

Closed sebastianpopp closed 3 years ago

sebastianpopp commented 3 years ago

If I have an image with a size of 1024x553 pixel and I run

(new \League\Glide\Manipulators\Size)
    ->setParams(['w' => 411, 'fit' => 'max'])
    ->run($image);

on it. I will get an image with the dimensions 409x221 pixel.

It looks like this happens due to the calculations in \League\Glide\Manipulators\Size::resolveMissingDimensions(). For the example above it will keep the width of 411 px and calculate a height of 221 px. Intervention Image rounds numbers differently, resulting in this wrong image size when the image is actually resized to the precalculated size.

To fix this issue I would suggest to rely on the resizing logic of Intervention Image.

rjd22 commented 3 years ago

I saw the GD issue was fixed so if you rebase it on the last master most likely the CI will pass.

ADmad commented 3 years ago

Thanks for nudging this along @rjd22 :slightly_smiling_face:.