From 103f9646ef22b7e639707acc5d605f05e6bb2433 Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Fri, 29 Nov 2013 11:30:25 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D1=80=D0=B5=D1=81=D0=B0?= =?UTF-8?q?=D0=B9=D0=B7=D0=B8=D0=BD=D0=B3=D0=B0=20=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=20crop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resize.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/resize.py b/resize.py index 111727a..4e4099e 100755 --- a/resize.py +++ b/resize.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import division import os, sys from PIL import Image from PIL import ImageEnhance @@ -19,14 +20,15 @@ try: im = im.convert() if args.crop: width_crop = im.size[0] - height_crop = im.size[0]*(args.width/args.height) + height_crop = int(im.size[0]/(args.width/args.height)) width_padding = 0 - height_padding = (im.size[1]-height_crop)/2 + height_padding = int((im.size[1]-height_crop)/2) if height_crop > im.size[1]: - width_crop = im.size[1]*(args.height/args.width) + width_crop = int(im.size[1]/(args.height/args.width)) height_crop = im.size[1] - width_padding = (im.size[0]-width_crop)/2 + width_padding = int((im.size[0]-width_crop)/2) height_padding = 0 + print((width_padding, height_padding, width_crop+width_padding, height_crop+height_padding)) im_crop = im.crop((width_padding, height_padding, width_crop+width_padding, height_crop+height_padding)) im_result = im_crop.resize(size, Image.ANTIALIAS) else: