From dbed55655a9c0d6e59a5aafc60c364c66fcacf62 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Wed, 17 Feb 2016 00:28:19 +0100 Subject: [PATCH] fix JPEG2000 handling after move to Python3 --- src/jp2.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/jp2.py b/src/jp2.py index 644cb12..53e118f 100644 --- a/src/jp2.py +++ b/src/jp2.py @@ -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: