diff options
author | Jason Ekstrand <jason.ekstrand@intel.com> | 2015-12-08 14:23:53 -0800 |
---|---|---|
committer | Jason Ekstrand <jason.ekstrand@intel.com> | 2015-12-08 14:34:48 -0800 |
commit | e7451f4361c5c79b4f96297a1aff6630a3aab083 (patch) | |
tree | 7cd1275e19ad19a3d05cd2e9b6dd10155c7dcaa3 /misc | |
parent | 8db88894655efa8223cbd7e9a059af0afc832446 (diff) |
gen_image: Take an operation parameter
Diffstat (limited to 'misc')
-rwxr-xr-x | misc/gen_image | 7 |
1 files changed, 6 insertions, 1 deletions
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) |