1
0
Fork 0
forked from josch/img2pdf

fix JPEG2000 handling after move to Python3

This commit is contained in:
Johannes 'josch' Schauer 2016-02-17 00:28:19 +01:00
parent 27015c1a6e
commit dbed55655a

View file

@ -64,9 +64,9 @@ def parse_jp2h(data):
while byteStart < noBytes and boxLengthValue != 0:
boxLengthValue, boxType, byteEnd, boxContents = \
getBox(data, byteStart, noBytes)
if boxType == 'ihdr':
if boxType == b'ihdr':
width, height = parse_ihdr(boxContents)
elif boxType == 'colr':
elif boxType == b'colr':
colorspace = parse_colr(boxContents)
byteStart = byteEnd
return (width, height, colorspace)
@ -76,10 +76,13 @@ def parsejp2(data):
noBytes = len(data)
byteStart = 0
boxLengthValue = 1 # dummy value for while loop condition
width = None
height = None
colorspace = None
while byteStart < noBytes and boxLengthValue != 0:
boxLengthValue, boxType, byteEnd, boxContents = \
getBox(data, byteStart, noBytes)
if boxType == 'jp2h':
if boxType == b'jp2h':
width, height, colorspace = parse_jp2h(boxContents)
byteStart = byteEnd
if not width: