Skip to content

Instantly share code, notes, and snippets.

@juan-fdz-hawa
Last active October 26, 2016 16:16
Show Gist options
  • Save juan-fdz-hawa/dd51d105f0393b5df099f5995f5c72a2 to your computer and use it in GitHub Desktop.
Save juan-fdz-hawa/dd51d105f0393b5df099f5995f5c72a2 to your computer and use it in GitHub Desktop.
import struct
fmt = '<3s3sHH'
with open('filter.gif', 'rb') as fp:
img = memoryview(fp.read())
header = img[:10]
bytes(header)
#b'GIF89a+\x02\xe6\x00'
struct.unpack(fmt, header)
#(b'GIF', b'89a', 555, 230)
del header
del img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment