I have an image that I want to resize - but can tolerate rescaling. The suggestions I have found all maintain the aspect ratio -
import os, sys
import Image
size = 128, 128
for infile in sys.argv[1:]:
outfile = os.path.splitext(infile)[0] + ".thumbnail"
if infile != outfile:
try:
im = Image.open(infile)
im.thumbnail(size, Image.ANTIALIAS)
im.save(outfile, "JPEG")
except IOError:
print "cannot create thumbnail for '%s'" % infile
I've tried thumbnail and resize - but they are maintain aspect. How can I resize/rescale without maintaining aspect?