File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -424,8 +424,9 @@ def test_pclr() -> None:
424
424
425
425
426
426
def test_comment () -> None :
427
- with Image .open ("Tests/images/comment.jp2" ) as im :
428
- assert im .info ["comment" ] == b"Created by OpenJPEG version 2.5.0"
427
+ for path in ("Tests/images/9bit.j2k" , "Tests/images/comment.jp2" ):
428
+ with Image .open (path ) as im :
429
+ assert im .info ["comment" ] == b"Created by OpenJPEG version 2.5.0"
429
430
430
431
# Test an image that is truncated partway through a codestream
431
432
with open ("Tests/images/comment.jp2" , "rb" ) as fp :
Original file line number Diff line number Diff line change @@ -252,6 +252,7 @@ def _open(self) -> None:
252
252
if sig == b"\xff \x4f \xff \x51 " :
253
253
self .codec = "j2k"
254
254
self ._size , self ._mode = _parse_codestream (self .fp )
255
+ self ._parse_comment ()
255
256
else :
256
257
sig = sig + self .fp .read (8 )
257
258
@@ -262,6 +263,9 @@ def _open(self) -> None:
262
263
if dpi is not None :
263
264
self .info ["dpi" ] = dpi
264
265
if self .fp .read (12 ).endswith (b"jp2c\xff \x4f \xff \x51 " ):
266
+ hdr = self .fp .read (2 )
267
+ length = _binary .i16be (hdr )
268
+ self .fp .seek (length - 2 , os .SEEK_CUR )
265
269
self ._parse_comment ()
266
270
else :
267
271
msg = "not a JPEG 2000 file"
@@ -296,10 +300,6 @@ def _open(self) -> None:
296
300
]
297
301
298
302
def _parse_comment (self ) -> None :
299
- hdr = self .fp .read (2 )
300
- length = _binary .i16be (hdr )
301
- self .fp .seek (length - 2 , os .SEEK_CUR )
302
-
303
303
while True :
304
304
marker = self .fp .read (2 )
305
305
if not marker :
You can’t perform that action at this time.
0 commit comments