Skip to content

[TIKA-4773] Expose all parsed XMP properties from images#2927

Open
dschmidt wants to merge 1 commit into
apache:mainfrom
dschmidt:expose-all-xmp-properties
Open

[TIKA-4773] Expose all parsed XMP properties from images#2927
dschmidt wants to merge 1 commit into
apache:mainfrom
dschmidt:expose-all-xmp-properties

Conversation

@dschmidt

@dschmidt dschmidt commented Jul 5, 2026

Copy link
Copy Markdown

Metadata Extractor parses the whole XMP packet, but the image extractor only copies the Dublin Core and XMP-MM schemas into the metadata. Everything else is parsed and then dropped, including vendor namespaces such as the ones Google Motion Photos use.

This adds a handler that copies all parsed XMP properties (keyed by their prefix:name path) and skips keys that already map to a known Tika field, so normalized values are not shadowed.

It also pre-registers canonical prefixes for the Google photo namespaces. XMPCore's namespace registry is process-global and keeps whichever prefix the first parsed file declares for a URI, so the same namespace can otherwise surface as Camera or GCamera depending on parse order; pinning the prefixes keeps the keys stable.

Example output for a Motion Photo, alongside the usual EXIF:

Camera:MotionPhoto = 1
Camera:MotionPhotoVersion = 1
Camera:MotionPhotoPresentationTimestampUs = 500000
Container:Directory[2]/Item:Semantic = MotionPhoto
Container:Directory[2]/Item:Length = 122562

Tests cover both the current Motion Photo format and the legacy MicroVideo format, using small synthetic files. mvn clean install for tika-parser-image-module passes (checkstyle, forbidden-apis, RAT, and the full test suite).

Note: I do not have an Apache JIRA account yet (requested). I will add the TIKA-XXXX id to the title and commit message once the issue is filed; opening now for early feedback.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 enhances the image parser’s metadata extraction to preserve and expose all XMP properties parsed by Metadata Extractor (including vendor namespaces like Google Motion Photos), and stabilizes namespace prefixes so extracted keys remain consistent across parse order.

Changes:

  • Add an XmpHandler to ImageMetadataExtractor to copy XMP properties from XmpDirectory#getXmpProperties() into Tika Metadata.
  • Pre-register canonical prefixes for Google Motion Photo-related namespaces to keep emitted XMP keys stable.
  • Add JUnit tests covering Motion Photo and legacy MicroVideo XMP extraction and prefix stability.

Reviewed changes

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

File Description
.../src/main/java/org/apache/tika/parser/image/ImageMetadataExtractor.java Adds a new handler to copy XMP properties into output metadata and registers stable namespace prefixes.
.../src/test/java/org/apache/tika/parser/image/MotionPhotoXmpTest.java Introduces tests asserting vendor XMP properties are exposed and canonical prefixes are used.

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

Comment on lines +349 to +353
String name = property.getKey();
String value = property.getValue();
if (value != null && !MetadataFields.isMetadataField(name)) {
metadata.set(name, value);
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point, fixed. It now also skips a key that already has a value, so it won't overwrite what other extractors set.

@dschmidt dschmidt force-pushed the expose-all-xmp-properties branch from 5063c3b to 085ed66 Compare July 6, 2026 07:22
@dschmidt dschmidt changed the title [TIKA-XXXX] Expose all parsed XMP properties from images [TIKA-4773] Expose all parsed XMP properties from images Jul 6, 2026
@dschmidt

dschmidt commented Jul 6, 2026

Copy link
Copy Markdown
Author

Adressed issues from the Copilot review and updated the title with the Jira ticket number :)

@THausherr THausherr requested a review from Copilot July 6, 2026 09:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.

Metadata Extractor parses the full XMP packet but only Dublin Core and XMP-MM
were copied to the metadata, so properties from other namespaces (e.g. Google
motion photo tags) were dropped. Copy all parsed XMP properties, and pin
canonical prefixes for the Google photo namespaces so keys do not depend on
parse order.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 4 changed files in this pull request and generated no new comments.

@dschmidt

dschmidt commented Jul 6, 2026

Copy link
Copy Markdown
Author

Dunno, how you want to handle the Copilot review(s) - I think I addressed all comments, but wanted to leave it up to you to resolve the conversations. Good?

@THausherr

Copy link
Copy Markdown
Contributor

I've pressed resolved. IMHO it is all good, lets wait if Tim has something to add.

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.

3 participants