MAXSIZEX = 64
MAXSIZEY = 42
width, height = im.size
xrat = width / float(MAXSIZEX)
yrat = height / float(MAXSIZEY)
if xrat < 1 or yrat < 1:
    rat = min(xrat, yrat)
im = im.resize((int(width / rat), int(height / rat)))
res = im.crop((0, 0, MAXSIZEX, MAXSIZEY))
res.show()
How to keep image alignment when cropping in Python?