Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for reading DPI information from JPEG2000 images #5568

Merged
merged 8 commits into from
Aug 2, 2021
3 changes: 0 additions & 3 deletions src/PIL/Jpeg2KImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ def _parse_jp2_header(fp):
if reader.read_fields(">4s")[0] == b"jpx ":
mimetype = "image/jpx"

if header is None:
raise SyntaxError("Could not find JP2 header")
Copy link
Contributor Author

@rogermb rogermb Aug 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, this is unreachable, reader.has_next_box() will never return False (because reader = BoxReader(fp) is initialized without a length), so the only possible outcome for a malformed image not containing a "jp2h" header is that reader.next_box_type() will eventually fail with some kind of exception.

While not exactly elegant, that's definitely better than having an if statement that misleads the reader. 👍


size = None
mode = None
bpc = None
Expand Down