Z
в моделях есть
def resize_avatar(model_object):
try:
if model_object.image_getted:
return
thmb = Image.open(model_object.avatar.file.name.encode('utf8'))
current_height = thmb.height
if current_height > 800:
current_height = 800
height = current_height
width = int(float(model_object.avatar.width) / (float(model_object.avatar.height) / float(height)))
size = (width, height)
if thmb.mode not in ('L', 'RGB'):
thmb = thmb.convert('RGB')
thmb = thmb.resize(size, Image.ANTIALIAS)
thmb.save(model_object.avatar.file.name.encode('utf8'))
except: