summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorChad Versace <chad.versace@intel.com>2015-07-23 10:13:39 -0700
committerChad Versace <chad.versace@intel.com>2015-07-23 13:32:47 -0700
commit38e8c1dcdacecd636926bcdea049d0468647c6ed (patch)
treeb8fe191b32375eb5cbc1781c27e086ed7daa4dc8 /misc
parentd256e8bec3affa9f64c8ff122f460ad78c69411e (diff)
data: Import 2 photos and generate grayscale images
Import the jpegs files, taken from my camera: grass-2014x1536.jpg pink-leaves-3264x2448.jpg Use ImageMagick at buildtime to generate grayscale PNG images from the JPEG files. Generate an image for each miplevel, beginning with the base level extent 2048x1024. Images will be used to fill depth and stencil miptrees.
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/gen_image58
1 files changed, 58 insertions, 0 deletions
diff --git a/misc/gen_image b/misc/gen_image
new file mode 100755
index 0000000..f9d6f5e
--- /dev/null
+++ b/misc/gen_image
@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+
+import argparse
+import os
+import re
+import sys
+
+from subprocess import check_call
+
+PROG_NAME = os.path.basename(sys.argv[0])
+
+def die(msg):
+ print('{}: error: {}'.format(PROG_NAME, msg), file=sys.stderr)
+ sys.exit(1)
+
+def parse_args():
+ p = argparse.ArgumentParser()
+ p.add_argument('--convert-tool', default='convert')
+ p.add_argument('-d', '--debug', action='store_true')
+ p.add_argument('src_filename')
+ p.add_argument('dest_filename')
+ return p.parse_args()
+
+def main():
+ args = parse_args()
+
+ src_filename = args.src_filename
+ dest_filename = args.dest_filename
+
+ # The badly named "convert" tool is an ImageMagick tool.
+ convert_args = [args.convert_tool, src_filename]
+
+ if re.search('grayscale', dest_filename):
+ convert_args += [
+ '-set', 'colorspace', 'Gray',
+ '-separate',
+ '-average',
+ ]
+
+ match = re.search(r'(\d+)x(\d+)', dest_filename)
+ if match is None:
+ die('dest_filename {!r} contains no size'.format(dest_filename))
+
+ width = match.groups(0)[0]
+ height = match.groups(0)[1]
+
+ convert_args += [
+ '-adaptive-resize', '{}x{}'.format(width, height),
+ dest_filename,
+ ]
+
+ if args.debug:
+ print('run: ' + ' '.join(map(repr, convert_args)))
+
+ check_call(convert_args)
+
+if __name__ == '__main__':
+ main()