Skip to content

Conversation

@lgritz
Copy link
Collaborator

@lgritz lgritz commented Dec 19, 2025

Each file writer that is capable of writing arbitrary metadata is supposed to tace care to suppress hints meant for other writers, or for OIIO in general, not interpret them as literal metadata to write to the file. PNG was not doing so, and ended up writing hints as literal metadata. This brings it in line with our behavior when writing OpenEXR and other formats.

Each file writer that is capable of writing arbitrary metadata is
supposed to tace care to suppress hints meant for other writers, or
for OIIO in general, not interpret them as literal metadata to write
to the file. PNG was not doing so, and ended up writing hints as
literal metadata. This brings it in line with our behavior when
writing OpenEXR and other formats.

Signed-off-by: Larry Gritz <[email protected]>
@lgritz lgritz requested review from brechtvl and Copilot December 19, 2025 01:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where the PNG writer was incorrectly writing metadata hints (intended for other file formats or OIIO itself) as literal metadata in PNG files. The fix adds logic to filter out metadata with namespace prefixes like "oiio:" or other format names (e.g., "exr:", "tiff:") before writing to PNG files, bringing PNG's behavior in line with other format writers like OpenEXR.

Key changes:

  • Added metadata filtering logic to suppress format-specific hints and OIIO-internal hints
  • Updated test reference output to reflect corrected chunk types in error messages

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/png.imageio/png_pvt.h Added metadata filtering to prevent writing format hints as literal PNG metadata
testsuite/png-damaged/ref/out.txt Updated test expectations to reflect correct PNG chunk types (oFFs vs tEXt)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 578 to 579
auto parts = Strutil::splitsv(name, ":", 2);
OIIO_DASSERT(parts.size() == 2);
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

The variable 'parts' is assigned but never used. This computation is unnecessary since the assertion only verifies the result. Consider removing this line and relying on the existing colonpos check.

Suggested change
auto parts = Strutil::splitsv(name, ":", 2);
OIIO_DASSERT(parts.size() == 2);

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right you are, Copilot! Those two lines were left over from a previous stab at implementing this, then I changed my mind but didn't clean up all the extraneous stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants