summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2015-12-08 14:23:53 -0800
committerJason Ekstrand <jason.ekstrand@intel.com>2015-12-08 14:34:48 -0800
commite7451f4361c5c79b4f96297a1aff6630a3aab083 (patch)
tree7cd1275e19ad19a3d05cd2e9b6dd10155c7dcaa3
parent8db88894655efa8223cbd7e9a059af0afc832446 (diff)
gen_image: Take an operation parameter
-rw-r--r--Makefile.am4
-rwxr-xr-xmisc/gen_image7
2 files changed, 8 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
index 5b75bfd..b6c02b4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -212,7 +212,7 @@ data/grass-2048x1024.jpg: $(srcdir)/data/grass-2014x1536.jpg
data/grass-%.png: \
$(srcdir)/data/grass-2048x1024.jpg \
$(srcdir)/misc/gen_image
- $(AM_V_GEN) $(PYTHON2) $(srcdir)/misc/gen_image $< $@
+ $(AM_V_GEN) $(PYTHON2) $(srcdir)/misc/gen_image scale $< $@
data/pink-leaves-2048x1024.jpg: $(srcdir)/data/pink-leaves-3264x2448.jpg
$(AM_V_GEN)
@@ -222,7 +222,7 @@ data/pink-leaves-2048x1024.jpg: $(srcdir)/data/pink-leaves-3264x2448.jpg
data/pink-leaves-%.png: \
$(srcdir)/data/pink-leaves-2048x1024.jpg \
$(srcdir)/misc/gen_image
- $(AM_V_GEN) $(PYTHON2) $(srcdir)/misc/gen_image $< $@
+ $(AM_V_GEN) $(PYTHON2) $(srcdir)/misc/gen_image scale $< $@
TESTS = \
src/tests/self/bad-test-names.bash \
diff --git a/misc/gen_image b/misc/gen_image
index 2575d41..50d79fa 100755
--- a/misc/gen_image
+++ b/misc/gen_image
@@ -16,6 +16,7 @@ def die(msg):
def parse_args():
p = argparse.ArgumentParser()
+ p.add_argument('operation')
p.add_argument('src_filename')
p.add_argument('dest_filename')
return p.parse_args()
@@ -25,6 +26,7 @@ def main():
src_filename = args.src_filename
dest_filename = args.dest_filename
+ operation = args.operation
if re.search('grayscale', dest_filename):
imread_flags = cv2.IMREAD_GRAYSCALE
@@ -40,7 +42,10 @@ def main():
width = int(match.groups(0)[0])
height = int(match.groups(0)[1])
- res = cv2.resize(img, (width, height), interpolation = cv2.INTER_CUBIC)
+ if operation == 'scale':
+ res = cv2.resize(img, (width, height), interpolation = cv2.INTER_CUBIC)
+ else:
+ die('invalid operation: {!r}'.format(dest_filename))
cv2.imwrite(dest_filename, res)