# -*- Mode: Python -*- # if you enjoy your stereo images cross-eyed (or wide-eyed, try the # '-r' option) rather than through silly colored glasses, use this # utility. # # some great anaglyphs can be found here: # http://www.hq.nasa.gov/office/pao/History/alsj/a11/images11.html # import os import sys if '-r' in sys.argv: sys.argv.remove ('-r') reverse = True else: reverse = False if len(sys.argv) < 2: print 'Usage: unanaglyph.py ' print ' stdin should be a ppm image, either 16 or 8-bit.' else: name = sys.argv[1] # should create three files, noname.{red,grn,blu} os.system ('pnmdepth 255 | ppmtorgb3') if reverse: os.system ('pnmcat -lr noname.red noname.blu | cjpeg > %s.jpg' % (name,)) else: os.system ('pnmcat -lr noname.blu noname.red | cjpeg > %s.jpg' % (name,)) # throw away the temp files os.unlink ('noname.red') os.unlink ('noname.blu') os.unlink ('noname.grn') # useful on the mac os.system ('open %s.jpg' % (name,))