Skip to content

Instantly share code, notes, and snippets.



Created Jun 26, 2016
What would you like to do?
#!/usr/bin/env python3
from io import open
from collections import deque
IHDR = b'\x69\x68\x64\x72' # See I.5.3.1 Image Header box
with open('tests/fixtures/images/color.jp2', 'rb') as jp2:
window = deque([], 4)
while bytes(b''.join(window)) != IHDR:
# The image header box is the only place in the spec where height comes
# first. Go figure.
image_height = int.from_bytes(, byteorder='big', signed=False)
image_width = int.from_bytes(, byteorder='big', signed=False)
print(image_width, image_height)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.