diff options
author | jaseg <s@jaseg.de> | 2013-04-06 16:26:13 +0200 |
---|---|---|
committer | jaseg <s@jaseg.de> | 2013-04-06 16:26:28 +0200 |
commit | d09a64ce01b37fa67c905df1a28f81f91d59e065 (patch) | |
tree | 8c4c7c7b8bdb0c7aedf9c26c590eec17c5d5828e | |
parent | 8b20e1d4336f5ba5bb28ef2176abacfe832968b2 (diff) | |
download | pixelterm-d09a64ce01b37fa67c905df1a28f81f91d59e065.tar.gz pixelterm-d09a64ce01b37fa67c905df1a28f81f91d59e065.tar.bz2 pixelterm-d09a64ce01b37fa67c905df1a28f81f91d59e065.zip |
Added batch processing to unpixelterm
-rwxr-xr-x | unpixelterm.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/unpixelterm.py b/unpixelterm.py index 4091dfb..0969a8f 100755 --- a/unpixelterm.py +++ b/unpixelterm.py @@ -86,13 +86,17 @@ def unpixelterm(text): if __name__ == '__main__': parser = argparse.ArgumentParser(description='Convert images rendered by pixelterm-like utilities back to PNG') - parser.add_argument('input', type=argparse.FileType('r')) - parser.add_argument('output', type=str) + parser.add_argument('input', type=argparse.FileType('r'), nargs='+') + parser.add_argument('-o', '--output', type=str, help='Output file name, defaults to ${input%.pony}.png') + parser.add_argument('-v', '--verbose', action='store_true') args = parser.parse_args() - img, metadata = unpixelterm(args.input.read()) - print('Metadata:') - pnginfo = PngImagePlugin.PngInfo() - for k, v in metadata.items(): - print('{:15}: {}'.format(k, '/'.join(v))) - pnginfo.add_text(k, '/'.join(v)) - img.save(args.output, 'PNG', pnginfo=pnginfo) + for f in args.input: + img, metadata = unpixelterm(f.read()) + if args.verbose: + print('Metadata:') + pnginfo = PngImagePlugin.PngInfo() + for k, v in metadata.items(): + if args.verbose: + print('{:15}: {}'.format(k, '/'.join(v))) + pnginfo.add_text(k, '/'.join(v)) + img.save(args.output or f.name.rstrip('.pony')+'.png', 'PNG', pnginfo=pnginfo) |