fix(jpeg): be a little more flexible with corrupt IPTC blocks#5140
Merged
lgritz merged 1 commit intoAcademySoftwareFoundation:mainfrom Apr 13, 2026
Merged
fix(jpeg): be a little more flexible with corrupt IPTC blocks#5140lgritz merged 1 commit intoAcademySoftwareFoundation:mainfrom
lgritz merged 1 commit intoAcademySoftwareFoundation:mainfrom
Conversation
PR 5081 added more detection of corruptions in (among other places) the IPTC blocks in a JPEG file. But we maybe got a little too aggressive, since there appear to be some jpg files out there that don't have correct IPTC blocks but are otherwise fine. Well, the IPTC block may be bad, but nothing else is wrong with the file. I don't want to point fingers, but maybe it's PhotoShop writing the strange IPTC blocks (maybe many years old versions). Anyway, I noticed that we take the following approach with ICC profiles in JPEG files: we use the OIIO attribute "imageinput:strict" to decide whether a localized corruption in the ICC profile ONLY causes the ICC profile to be skipped (reading the pixels just fine), or if anything suspicious is grounds to stop reading the file entirely and declare it corrupt. So I'm using the same control for the analogous purpose when reading the IPTC blocks. By default, just skip the IPTC block if we don't know how to decode it. But if in strict mode, drop it immeditely and run away. I needed to update the jpeg-corrupt test to force strict node, and update some some ref outputs. Signed-off-by: Larry Gritz <lg@larrygritz.com>
Collaborator
Author
|
I need this at work, if any has time to give it a review |
lgritz
added a commit
to lgritz/OpenImageIO
that referenced
this pull request
Apr 13, 2026
…ySoftwareFoundation#5140) Recent PR AcademySoftwareFoundation#5081 added more detection of corruptions in (among other places) the IPTC blocks in a JPEG file. But we maybe got a little too aggressive, since there appear to be some jpg files out there that have strange (maybe technically incorrect?) IPTC blocks but are otherwise fine. Anyway, I noticed that for ICC profiles in JPEG files, we use the OIIO attribute "imageinput:strict" to decide whether a localized corruption in the ICC profile ONLY causes the ICC profile to be skipped (reading the pixels just fine), or a stricter mode where anything suspicious is grounds to stop reading the file entirely and declare it corrupt. So in this patch, I'm using the same control for the analogous purpose when reading the IPTC blocks. By default, just skip the IPTC block if we don't know how to decode it. But if in strict mode, make a full error that will cause us to stop reading the file. With this change, I needed to update the jpeg-corrupt test to force strict node, and update some some ref outputs. Signed-off-by: Larry Gritz <lg@larrygritz.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recent PR #5081 added more detection of corruptions in (among other places) the IPTC blocks in a JPEG file.
But we maybe got a little too aggressive, since there appear to be some jpg files out there that have strange (maybe technically incorrect?) IPTC blocks but are otherwise fine.
Anyway, I noticed that for ICC profiles in JPEG files, we use the OIIO attribute "imageinput:strict" to decide whether a localized corruption in the ICC profile ONLY causes the ICC profile to be skipped (reading the pixels just fine), or a stricter mode where anything suspicious is grounds to stop reading the file entirely and declare it corrupt.
So in this patch, I'm using the same control for the analogous purpose when reading the IPTC blocks. By default, just skip the IPTC block if we don't know how to decode it. But if in strict mode, make a full error that will cause us to stop reading the file.
With this change, I needed to update the jpeg-corrupt test to force strict node, and update some some ref outputs.