DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Simple Resize PIL Image With Python
// description of your code here
def resize(im,percent):
""" retaille suivant un pourcentage 'percent' """
w,h = im.size
return im.resize(((percent*w)/100,(percent*h)/100))
def resize2(im,pixels):
""" retaille le coté le plus long en 'pixels'
(pour tenir dans une frame de pixels x pixels)
"""
(wx,wy) = im.size
rx=1.0*wx/pixels
ry=1.0*wy/pixels
if rx>ry:
rr=rx
else:
rr=ry
return im.resize((int(wx/rr), int(wy/rr)))





