From: James Thewlis Date: Fri, 27 Jun 2014 09:49:08 +0000 (+0100) Subject: Make resizing & cropping with PIL work X-Git-Tag: submit/tizen/20180823.020014~653^2~85^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=423808dd60c5077dda16432080caa69a2e6f8d13;p=platform%2Fupstream%2Fcaffeonacl.git Make resizing & cropping with PIL work Previously it was trying to use undefined variables --- 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