Resize image by height or width

The original size of the image is 1455*1940px.

When I apply resize(1440, 1440) the result is 14401920px, instead of what I thought 10801440px.

How do I make sure the height or the width doesn’t exceed 1440 in this case?

If you did it like this resize(1080, null) I would resize to 1080 wide, and the height would fit the images aspect ratio, but wont neccissarily be 1440 (i cant do that math in my head). Basiclly if you pass null on the lenght you dont care about, it will keep the ratio. Giving it both numbers wont necceritly work out as you expect, beacuse it fits the image to the dimensions you give - the image needs to be large enough in other words.

If you want more precision, its worth looking at the focuscrop plugin, because this will allow you to make a perfect size that you want but it will trim the edges to make it fit, instead of resizing, so its a crop rather than a resize. the plugin allows you to pick a focal point on the image, like someones face for example, which will base the crop around that point. The Kirby built in crop works from images center point, which can lead to headless portraits if your not careful.


Other plugin options:


Thanks for the suggestions! Will take a look :+1: