Skip to content

Conversation

1c3t3a
Copy link
Contributor

@1c3t3a 1c3t3a commented Sep 22, 2025

This change adds an iptc_metadata method (similar to xmp_metadata and exif_metadata) to the ImageDecoder and implements it for PNG and JPG.

This is related to #2610. If my research was correct and IPTC metadata only exists in PNG and JPG, then this should fix the issue.

This change adds an `iptc_metadata` method (similar to `xmp_metadata` and
`exif_metadata`) to the `ImageDecoder` and implements it for PNG and JPG.
@1c3t3a

This comment was marked as outdated.

@1c3t3a 1c3t3a changed the title Expose IPTC metadata for PNG and JPG Expose IPTC metadata for PNG, JPG and Tiff Sep 22, 2025
Comment on lines +540 to +545
/// This method converts a `Value` to a vector of bytes. A `Value` in Tiff can have different
/// types, e.g. a byte, a short or a float. This method intents to convert all these types to
/// a vector of bytes (e.g. a u32 can be represented as a [u8; 4]). However, since this is only
/// intended to parse values stored in XMP, IPTC and EXIF metadata sections, we ignore / return
/// an error on a few Values that don't make sense in this context (e.g. Value::Ifd).
fn value_to_bytes(value: Value, bytes: &mut Vec<u8>) -> ImageResult<()> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know that this is most likely not ideal. There is a discussion between me an @197g here, where Aurelia points out how to archieve this properly as part of the Tiff crate.

I put this change into a separate commit and I can drop it here and get to first do it properly in tiff, if that is requested.

Copy link
Member

Choose a reason for hiding this comment

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

The one thing I'd worry about here is architectural difference. Since this is doing little-endian conversion it makes me suspicious it may only work on little endian targets? Then again, to quote Linus Torvalds, "Oh Christ. Is somebody seriously working on BE support in 2025?" so I think this may be fine if we first check target_endianess and always error for non-little targets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I came up with this piece of code during the CI run which I think was running this on BE? I might misunderstood sth there :) Alternatively we could also just handle endianess correctly? I am also fine with erroring out, though!

@1c3t3a
Copy link
Contributor Author

1c3t3a commented Sep 22, 2025

The CI failure seems to be due to a spurious network failure in a setup step. Is there a way to retrigger the run?

@1c3t3a
Copy link
Contributor Author

1c3t3a commented Oct 9, 2025

Friendly ping on this PR, would anyone have a moment to take a look? :)

Copy link
Member

@197g 197g left a comment

Choose a reason for hiding this comment

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

Thanks for the reminder, got deep into other aspects. Except for the tiff aspect this LGTM, certainly that we do expose this in the same manner as other kinds of metadata.

Comment on lines +540 to +545
/// This method converts a `Value` to a vector of bytes. A `Value` in Tiff can have different
/// types, e.g. a byte, a short or a float. This method intents to convert all these types to
/// a vector of bytes (e.g. a u32 can be represented as a [u8; 4]). However, since this is only
/// intended to parse values stored in XMP, IPTC and EXIF metadata sections, we ignore / return
/// an error on a few Values that don't make sense in this context (e.g. Value::Ifd).
fn value_to_bytes(value: Value, bytes: &mut Vec<u8>) -> ImageResult<()> {
Copy link
Member

Choose a reason for hiding this comment

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

The one thing I'd worry about here is architectural difference. Since this is doing little-endian conversion it makes me suspicious it may only work on little endian targets? Then again, to quote Linus Torvalds, "Oh Christ. Is somebody seriously working on BE support in 2025?" so I think this may be fine if we first check target_endianess and always error for non-little targets.

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