Added support for unpng

This commit is contained in:
ej 2013-09-03 21:04:32 -04:00
parent 409dcfac31
commit e4d2cb3ea0
2 changed files with 28 additions and 4 deletions

View file

@ -10,16 +10,31 @@
import sys
import argparse
def pngit(infile, outfile):
def pngit(infile, outfile, nowrite=0):
outcounter = 0
with open(outfile, "wb") as theoutf:
theoutf.write("\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
if nowrite == 0:
theoutf.write("\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
with open(infile, "rb") as f:
byte = f.read(1)
while byte != "":
theoutf.write(byte)
if outcounter >= nowrite:
theoutf.write(byte)
else:
outcounter+=1
byte = f.read(1)
def unpngit(infile, outfile):
pngit(infile, outfile, 8)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('-i', '--input', help='the input file you want to perform a png or unpng operation on.')