mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-04 20:03:20 +03:00
raise SyntaxError when parsing codestream rather than returning an empty string
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
parent
a596a4063d
commit
58d5a73fac
|
@ -97,7 +97,7 @@ class BoxReader:
|
||||||
return tbox
|
return tbox
|
||||||
|
|
||||||
|
|
||||||
def _parse_codestream(fp):
|
def _parse_codestream(fp) -> tuple[tuple[int, int], str]:
|
||||||
"""Parse the JPEG 2000 codestream to extract the size and component
|
"""Parse the JPEG 2000 codestream to extract the size and component
|
||||||
count from the SIZ marker segment, returning a PIL (size, mode) tuple."""
|
count from the SIZ marker segment, returning a PIL (size, mode) tuple."""
|
||||||
|
|
||||||
|
@ -122,7 +122,8 @@ def _parse_codestream(fp):
|
||||||
elif csiz == 4:
|
elif csiz == 4:
|
||||||
mode = "RGBA"
|
mode = "RGBA"
|
||||||
else:
|
else:
|
||||||
mode = ""
|
msg = "unable to determine J2K image mode"
|
||||||
|
raise SyntaxError(msg)
|
||||||
|
|
||||||
return size, mode
|
return size, mode
|
||||||
|
|
||||||
|
@ -237,10 +238,6 @@ class Jpeg2KImageFile(ImageFile.ImageFile):
|
||||||
msg = "not a JPEG 2000 file"
|
msg = "not a JPEG 2000 file"
|
||||||
raise SyntaxError(msg)
|
raise SyntaxError(msg)
|
||||||
|
|
||||||
if self.size is None or not self.mode:
|
|
||||||
msg = "unable to determine size/mode"
|
|
||||||
raise SyntaxError(msg)
|
|
||||||
|
|
||||||
self._reduce = 0
|
self._reduce = 0
|
||||||
self.layers = 0
|
self.layers = 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user