diff --git a/README.md b/README.md index a20aff7..15d5534 100644 --- a/README.md +++ b/README.md @@ -1 +1,10 @@ -hello how are you doing toda + +```bash +e ~/Desktop/projects/pnger :) shasum README.md +96313bbb41092391c6df854d0bf6c9b7e1fe71fd README.md +e ~/Desktop/projects/pnger :) python pnger.py -i README.md -o testing.png +e ~/Desktop/projects/pnger :) python pnger.py -i testing.png -o test.txt -u +e ~/Desktop/projects/pnger :) shasum test.txt +96313bbb41092391c6df854d0bf6c9b7e1fe71fd test.txt +e ~/Desktop/projects/pnger :) +``` diff --git a/pnger.py b/pnger.py index cd3d6df..81932db 100644 --- a/pnger.py +++ b/pnger.py @@ -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.')