Skip to content

Preserving aspect ratio when cropping despite source image size

Compare
Choose a tag to compare
@weotch weotch released this 29 Jun 17:38

Previously, if an image was smaller than the requested dimensions, the image was not cropped at all. So if you called Croppa::url($url, 500,500) image but the source was 500x400, you would get the original 500x400 image outputted.

Now, Croppa will give you a 400x400 image. In other words, it is preserving the original aspect ratio despite the source image size. This is important if you are showing a bunch of images in a grid and don't want gaps but you can't be sure that the source images are all big enough.

This release also adds a upscale option that will tell Croppa to scale up images to match your requested dimensions. So, using the example above, with upscale set to 1, you will get a 500x500 image.