Oliver
Oliver

Reputation: 9498

Crop large images, but pad small ones

I want to display a 1920px by 335px version of user provided images on a web site, using ImageResizer v4.

I would like to use cropping in case the image is larger than the given dimensions, but padding if it is smaller, and in between I would like to shrink the image and add padding to achieve the target dimensions.

I know I can do cropping using ?w=1920&h=335&mode=crop but it won't reach the target dimensions if it is too small. Adding &scale=up will not look good on small images because the image is then first scaled up and then cropped.

On the other hand, using padding I would give away a lot of image pixels in case of large source images, when I could really crop them (down) to the target size.

Can anybody advise?

Upvotes: 0

Views: 44

Answers (1)

Lilith River
Lilith River

Reputation: 16468

Combine &mode=crop with &scale=canvas to achieve this.

Upvotes: 1

Related Questions