Re: Howto Extract PNG from binary file @ 0x80?

From: flamesrock (flamesrock_at_gmail.com)
Date: 01/04/05


Date: 3 Jan 2005 18:23:52 -0800

omg, it works!! thankyou!!!!!
and thankyou again, Frederick for the original code!

I've discovered a weird thing when changing header = infile.read(8) to
header = infile.read(4):
For some reason, the extracted png image is the exact same size as the
savegame archive (10.1 megs.) When reading 8bytes, its closer to
~200kb. Any clue as to why that is?

-thanks

#import struct
#
#def pngcopy(infile, outfile):
#
# # copy header
# header = infile.read(8)
# if header != "\211PNG\r\n\032\n":
# raise IOError("not a valid PNG file")
# outfile.write(header)
#
# # copy chunks, until IEND
# while 1:
# chunk = infile.read(8)
# size, cid = struct.unpack("!l4s", chunk)
# outfile.write(chunk)
# outfile.write(infile.read(size))
# outfile.write(infile.read(4)) # checksum
# if cid == "IEND":
# break
#
#
#infile = open("mysimcityfile.sc4", "rb")
#infile.seek(96)
###print (infile.read(4))
#outfile = open("myimage.png", "wb")
#pngcopy(infile, outfile)
#outfile.close()
#infile.close()

(http://simcitysphere.com/peachville.sc4)



Relevant Pages

  • Re: Perl script to clean up file -- Dont know if it can be done
    ... > has a header and footer, as well as page breaks, this is all in ASCII ... stuff and doing the transformation). ... my $outfile = 'outfile'; ...
    (comp.lang.perl.misc)
  • Re: Export Text File consisting header and table
    ... > Frist line is a header record such as "this is the header". ... print #outfile, padright); ... temp = Right& CStr, ...
    (microsoft.public.access.modulesdaovba)
  • Re: Merge part of CSV files
    ... They all have a header ... line, a single data line and footer line, but it is only the data line ... footer lines are not required at all. ... print OUTFILE counter, line ...
    (comp.lang.perl.misc)
  • Re: awk help!
    ... litd99 wrote: ... OK, to speed things up, you could try separating the header lines right ... head -3 infile> outfile ...
    (comp.unix.shell)
  • Re: awk help!
    ... OK, to speed things up, you could try separating the header lines right ... head -3 infile> outfile ...
    (comp.unix.shell)