summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Thewlis <jamt9000@gmail.com>2014-06-27 10:49:08 +0100
committerJames Thewlis <jamt9000@gmail.com>2014-06-27 10:55:12 +0100
commit423808dd60c5077dda16432080caa69a2e6f8d13 (patch)
tree8a3e102a5dfda1cbc17fe89e551a8d8b4a9dd3a9
parent71d6429c4d50e4f21a91b8de4a8696b27a294883 (diff)
downloadcaffeonacl-423808dd60c5077dda16432080caa69a2e6f8d13.tar.gz
caffeonacl-423808dd60c5077dda16432080caa69a2e6f8d13.tar.bz2
caffeonacl-423808dd60c5077dda16432080caa69a2e6f8d13.zip
Make resizing & cropping with PIL work
Previously it was trying to use undefined variables
-rwxr-xr-xtools/extra/resize_and_crop_images.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/extra/resize_and_crop_images.py b/tools/extra/resize_and_crop_images.py
index 0ab75dc2..c844f590 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