Question

I am trying to scale an incoming image which can be of (any type, any size) to a fixed grayscale image (eg 14x14). What I do is:

from PIL import Image
...
img = Image.open(args.picture).convert('L')
img.thumbnail( (14,14), Image.ANTIALIAS)   #img.resize returns Non-Type

but this returns a 12x14 instead of 14x14, due to the original aspect ratio apparently.

How would I achieve a 14x14, for any possible input?

Was it helpful?

Solution

The thumbnail entry from the PIL docs specifically says it maintains the aspect ratio of the original. Try using resize instead, it doesn't appear to maintain aspect ratio, at least from what I see.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top