Skip to content

Instantly share code, notes, and snippets.

@GiantRobato
Created August 4, 2018 04:21
Show Gist options
  • Save GiantRobato/5fd2513b73830584d6078c0fe9341c87 to your computer and use it in GitHub Desktop.
Save GiantRobato/5fd2513b73830584d6078c0fe9341c87 to your computer and use it in GitHub Desktop.
reads through all the chunks of a png file
while True:
chunk = f.read(4)
if not chunk: break
chunkType = f.read(4)
numBytes = int.from_bytes(chunk, byteorder='big')
data = f.read(numBytes)
crc = f.read(4)
print(chunkType)
print(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment