From 9516115f722fb3f95882553d8077bf1ab4a670ef Mon Sep 17 00:00:00 2001 From: Sergey Karayev Date: Tue, 26 Aug 2014 00:44:56 -0700 Subject: [PATCH] FIX web_demo upload was not processing grayscale correctly --- examples/web_demo/exifutil.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/web_demo/exifutil.py b/examples/web_demo/exifutil.py index 8c07aa8..01918b2 100644 --- a/examples/web_demo/exifutil.py +++ b/examples/web_demo/exifutil.py @@ -23,7 +23,13 @@ def open_oriented_im(im_path): if exif is not None and 274 in exif: orientation = exif[274] im = apply_orientation(im, orientation) - return np.asarray(im).astype(np.float32) / 255. + img = np.asarray(im).astype(np.float32) / 255. + if img.ndim == 2: + img = img[:, :, np.newaxis] + img = np.tile(img, (1, 1, 3)) + elif img.shape[2] == 4: + img = img[:, :, :3] + return img def apply_orientation(im, orientation): -- 2.7.4