Fixed so it actually outputs a real image

This commit is contained in:
ej 2013-09-03 21:35:48 -04:00
parent 2c48cce62a
commit 8327d0cce9

View file

@ -8,11 +8,16 @@
import sys import sys
import argparse import argparse
fakeimage = "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\x00\x00\x80\x00\x00\x00\x44\x08\x02\x00\x00\x00\xc6\x25\xaa\x3e\x00\x00\x00\xc2\x49\x44\x41\x54\x78\x5e\xed\xd4\x81\x06\xc3\x30\x14\x40\xd1\xb7\x34\xdd\xff\xff\x6f\xb3\x74\x56\xea\x89\x12\x6c\x28\x73\xe2\xaa\x34\x49\x03\x87\xd6\xfe\xd8\x7b\x89\xbb\x52\x8d\x3b\x87\xfe\x01\x00\x80\x00\x00\x10\x00\x00\x02\x00\x40\x00\x00\x08\x00\x00\x01\x00\x20\x00\x00\x04\x00\x80\x00\x00\x10\x00\x00\x02\x00\x40\x00\x00\x08\x00\x00\x01\x00\x20\x00\x00\x00\xd4\x5e\x6a\x64\x4b\x94\xf5\x98\x7c\xd1\xf4\x92\x5c\x5c\x3e\xcf\x9c\x3f\x73\x71\x58\x5f\xaf\x8b\x79\x5b\xee\x96\xb6\x47\xeb\xf1\xea\xd1\xce\xb6\xe3\x75\x3b\xe6\xb9\x95\x8d\xc7\xce\x03\x39\xc9\xaf\xc6\x33\x93\x7b\x66\x37\xcf\xab\xbf\xf9\xc9\x2f\x08\x80\x00\x00\x10\x00\x00\x02\x00\x40\x00\x00\x08\x00\x00\x01\x00\x20\x00\x00\x04\x00\x80\x00\x00\x10\x00\x00\x02\x00\x40\x00\x00\x08\x00\x00\x01\x00\x20\x00\x00\x8c\x37\xdb\x68\x03\x20\xfb\xed\x96\x65\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82"
def pngit(infile, outfile, nowrite=0): def pngit(infile, outfile, nowrite=0):
outcounter = 0 outcounter = 0
with open(outfile, "wb") as theoutf: with open(outfile, "wb") as theoutf:
if nowrite == 0: if nowrite == 0:
theoutf.write("\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") theoutf.write(fakeimage)
with open(infile, "rb") as f: with open(infile, "rb") as f:
byte = f.read(1) byte = f.read(1)
while byte != "": while byte != "":
@ -25,7 +30,7 @@ def pngit(infile, outfile, nowrite=0):
byte = f.read(1) byte = f.read(1)
def unpngit(infile, outfile): def unpngit(infile, outfile):
pngit(infile, outfile, 8) pngit(infile, outfile, 251)
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Process some integers.') parser = argparse.ArgumentParser(description='Process some integers.')