SmileyChris / easy-thumbnails

Easy thumbnails for Django
http://easy-thumbnails.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
1.37k stars 313 forks source link

Crop images while fitting inside specified size #424

Open zhgabor opened 7 years ago

zhgabor commented 7 years ago

I have not found anything besides to define a CUSTOM THUMBNAIL PROCESSOR to

make images to scale down proportionally and then scale long edge to fit the size then fill it with backgroundcolor

like this selection_986

xirdneh commented 6 years ago

I'm trying to figure out something like this, too. If i have an image that's 560x960 I would like to scale it to 1080x1080. But what happens is that the scale processor will scale up the image until the height is 1080 but the width would still be less than 1080. If I'm understanding you correctly the idea is to add whitespace (or whatever background color you want) to fit the actual size you want, right? I'm working on a custom tumbnail processor for this but was wondering if there's already a solution for this?

scorpp commented 5 years ago

we have exactly similar case where we need to generate Facebook\Tweeter meta-images for e-commerce products. We need aspect ratio ~2:1 and size ~1200x630 with empty space filled with background.

Btw for those ultimately looking for this functionality sorl-thumbnail can do this https://sorl-thumbnail.readthedocs.io/en/latest/template.html?highlight=padding#padding

fdemmer commented 3 years ago

easy-thumbnails can do that too: you have to set a background color for the space to be filled in in the processor configuration.