image icon indicating copy to clipboard operation
image copied to clipboard

Feature: allow resizing to smallest side.

Open robertmylne opened this issue 4 years ago • 1 comments

It would be nice if we could also scale to the smallest side.

Currently, if the original size was 800x600 it will be changed to 400x300 using the code below.

However, if we want to make sure all images are at least 400x400 as this is requirements for some sites, we can't do that. If it were to do that, the sizing would be 500x400 by pinning the value to the smallest side.

This makes sure it always fits the minimum requirements of 400x400 in this example.

Currently, there is no way to achieve this.

// resize the image so that the largest side fits within the limit; the smaller
// side will be scaled to maintain the original aspect ratio
$img->resize(400, 400, function ($constraint) {
    $constraint->aspectRatio();
    $constraint->upsize();
});

robertmylne avatar Apr 22 '21 03:04 robertmylne

What about heighten(), fit(), crop()?

medienhochdrei avatar May 20 '21 18:05 medienhochdrei

Maybe the pad() method in version 3 this is what you are looking for.

olivervogel avatar Dec 09 '23 15:12 olivervogel