Skip to content

Extract IPTC metadata from PNG text chunks - #723

Merged
drewnoakes merged 5 commits into
mainfrom
copilot/decode-iptc-metadata-png
Apr 21, 2026
Merged

Extract IPTC metadata from PNG text chunks#723
drewnoakes merged 5 commits into
mainfrom
copilot/decode-iptc-metadata-png

Conversation

Copilot AI commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

PngMetadataReader silently ignored IPTC data in PNG files. GIMP, ImageMagick, and Photoshop embed IPTC using a hex-encoded "raw profile" format stored in tEXt, zTXt, or iTXt chunks under the keyword Raw profile type iptc.

Changes

  • PngMetadataReader: In handlers for all three text chunk types, detect the Raw profile type iptc keyword and route decoded bytes to IptcReader instead of storing as generic text pairs
  • decodeRawProfile(): New private helper that parses the raw profile envelope format:
    \n
    iptc\n
          <length>\n
    <hex data, 72 chars/line>\n
    
    Handles Unix, Windows (\r\n), and legacy Mac (\r) line endings. Returns null on malformed input rather than throwing.

Test data added

Three minimal synthetic PNGs — one per chunk type (tEXt, zTXt, iTXt) — each carrying the same IPTC payload (object name, caption, two keywords), with corresponding assertions against IptcDirectory.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repository.sonatype.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.14/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/metadata-extractor/metadata-extractor org.codehaus.plexus.classworlds.launcher.Launcher test -pl . -Dtest=PngMetadataReaderTest -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Add functionality to extract IPTC metadata from PNG files Extract IPTC metadata from PNG text chunks Apr 20, 2026
Copilot AI requested a review from drewnoakes April 20, 2026 11:42
@drewnoakes
drewnoakes marked this pull request as ready for review April 21, 2026 12:43
@drewnoakes
drewnoakes merged commit a6b7122 into main Apr 21, 2026
4 checks passed
@drewnoakes
drewnoakes deleted the copilot/decode-iptc-metadata-png branch April 21, 2026 12:48
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.

How to extract IPTC metadata from PNG files?

2 participants