drewnoakes / metadata-extractor

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Apache License 2.0
2.59k stars 484 forks source link

How to extract IPTC metadata from PNG files? #673

Open drewnoakes opened 4 months ago

drewnoakes commented 4 months ago

Discussed in https://github.com/drewnoakes/metadata-extractor/discussions/672

Originally posted by **dhoffer** July 17, 2024 This is what is returned. Raw profile type iptc: IPTC profile 36 3842494d04040000000000181c0219000c74657374312c2074657374321c020000020004 So how can I decode this to get the actual metadata tags? My understanding (limited) is that these are stored in Photoshop metadata format inside the PNG. The actual metadata of the above as reported by exiftool. Keywords: test1, test2 How can I decode the same with metadata-extractor?
drewnoakes commented 4 months ago

Sample image provided by @dhoffer:

Standard_withKeywords

StefanOltmann commented 4 months ago

Hi @drewnoakes,

It’s a hex string that just needs to be decoded back to a byte array.

I solved that in my library like this: https://github.com/Ashampoo/kim/blob/83150150ea9e0e0aad637de72dbbf6b271cac7c2/src/commonMain/kotlin/com/ashampoo/kim/format/png/PngImageParser.kt#L166

Kind regards,

Stefan