Scrapy framework has the built-in capability to generate thumbnails. Is there any way to set a desired size for only one side in IMAGES_THUMBS to keep the original image proportion though?
Scrapy framework has the built-in capability to generate thumbnails. Is there any way to
Share
Had a look at Image.py in PIL module and it actually preserves the proportions automatically. The problem though that you can’t generate thumbnails of certain width or certain height – PIL will pick up either width or height depending on the original image and there’s no way to change that. Here’s the code that does the calculations.
The hacky way to do that is to set a really big value for the side you don’t care about, then the other side will always be used to generate the thumbnails.
So this does the trick for me:
Definitely not the best way, and it may stop working with the future versions of PIL but it’s good enough for now.
Still interested in a better way to achieve the same thing.