I need to resize images, from all different sizes to 144x144.
All sizes: from 968x565, from 25x48, from 400x400, etc. Don't know the input. I'm using Pillow library from Python. I don't mind losing aspect ratio.
Problem is: when using resize
method, some images get complete random sizes. Not always, but just some of them don't respect the arbitrary size of 144x144 I gave to the method. Here is a sample.
I tried resizing these images using Mac OS X Yosemite's Preview and it works flawlessly. What do I need to do in Pillow to force 144x144 size and work at least like Preview in mac?
I can't post the whole code, but the snippet that resizes is:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PIL import Image
im = Image.open('canvas_wheat.jpg')
im.resize((144, 144), Image.ANTIALIAS)
im.save('144.jpg', optimize=True, quality=20)
convert -size 952x804 xc:wheat canvas_wheat.jpg
. If you don't have it you can download the sample from imgur.com/DdxullE