From 423808dd60c5077dda16432080caa69a2e6f8d13 Mon Sep 17 00:00:00 2001 From: James Thewlis Date: Fri, 27 Jun 2014 10:49:08 +0100 Subject: [PATCH] Make resizing & cropping with PIL work Previously it was trying to use undefined variables --- tools/extra/resize_and_crop_images.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/extra/resize_and_crop_images.py b/tools/extra/resize_and_crop_images.py index 0ab75dc..c844f59 100755 --- a/tools/extra/resize_and_crop_images.py +++ b/tools/extra/resize_and_crop_images.py @@ -3,7 +3,7 @@ from mincepie import mapreducer, launcher import gflags import os import cv2 -import PIL +from PIL import Image # gflags gflags.DEFINE_string('image_lib', 'opencv', @@ -37,9 +37,10 @@ class OpenCVResizeCrop: class PILResizeCrop: ## http://united-coders.com/christian-harms/image-resizing-tips-every-coder-should-know/ - def resize_and_crop_image(self, input_file, output_file, output_side_length = 256): + def resize_and_crop_image(self, input_file, output_file, output_side_length = 256, fit = True): '''Downsample the image. ''' + img = Image.open(input_file) box = (output_side_length, output_side_length) #preresize image with factor 2, 4, 8 and fast algorithm factor = 1 -- 2.7.4