1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 23:38:09 +00:00

tools: add optional output parameter to toi2png

This commit is contained in:
Pavol Rusnak 2017-10-24 17:50:19 +02:00
parent 6e51ee251f
commit 34f363f903
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -23,7 +23,7 @@ def process_grayscale(w, h, data):
return bytes(pix)
def process_image(ifn):
def process_image(ifn, ofn):
data = open(ifn, 'rb').read()
@ -38,7 +38,8 @@ def process_image(ifn):
else:
print('Unsupported format')
return 3
ofn = '%s.png' % ifn[:-5]
if ofn is None:
ofn = '%s.png' % ifn[:-5]
w, h = struct.unpack('<HH', data[4:8])
@ -74,7 +75,7 @@ def process_image(ifn):
def main():
if len(sys.argv) < 2:
print('Usage: toi2png image.toi[fg]')
print('Usage: toi2png image.toi[fg] [output]')
return 1
ifn = sys.argv[1]
@ -82,7 +83,8 @@ def main():
print('Must provide TOIF/TOIG file')
return 2
process_image(ifn)
ofn = sys.argv[2] if len(sys.argv) > 2 else None
process_image(ifn, ofn)
main()