Unable to retrieve full text of title from JPEG metadata

两盒软妹~` 提交于 2019-12-11 00:58:02

问题


This is closely related to Extract IPTC-Keywords Longer than 64 Chars in Java . Please see my comments there.

The problem is that a title added to a JPEG file in Adobe Bridge as "Document Title" in the description tab (also shown as "Title" in the Details tab of the Windows File Properties dialog) ends up in two places in the JPEG file, as can be seen in a hex display of the file. One has the full title and one has only 64 characters' worth.

I can get the truncated one (tag name "Object Name") by retrieving all the tag descriptions in all the metadata directories, but I can't get the full title.

Here is an example file, whose embedded title is "Early morning on the spit between Waiohai Beach Club and Poipu Beach Park":


回答1:


I'd be happy to take a look at this for you. However imgur has stripped the metadata from that file.

Could you open an issue on the GitHub project instead? Any attached image there won't have the metadata removed:

https://github.com/drewnoakes/metadata-extractor/issues/new

Please also mention whether you grant permission to use the image in the project's regression test data set.


What I can see from your other post is that the longer form you're referencing is:

That string is within XMP data (as evidenced by the RDF XML surrounding it). You can access it with code resembling:

// Extract metadata from the image
Metadata metadata = ImageMetadataReader.readMetadata(image);

// Iterate through any XMP directories we may have received
for (XmpDirectory xmpDirectory : metadata.getDirectoriesOfType(XmpDirectory.class)) {

    // Usually with metadata-extractor, you iterate a directory's tags. However XMP has
    // a complex structure with many potentially unknown properties. This doesn't map
    // well to metadata-extractor's directory-and-tag model.
    //
    // If you need to use XMP data, access the XMPMeta object directly.
    XMPMeta xmpMeta = xmpDirectory.getXMPMeta();

    // Iterate XMP properties
    XMPIterator itr = xmpMeta.iterator();
    while (itr.hasNext()) {
        XMPPropertyInfo property = (XMPPropertyInfo) itr.next();

        // Print details of the property
        System.out.println(property.getPath() + ": " + property.getValue());
    }
}

I'd still like to see a sample image, but having seen your screenshots from the hex editor, I suspect Adobe Bridge is truncating the string to 64 bytes for IPTC. A quick search online suggests that's the maximum length for the IPTC keywords field.



来源:https://stackoverflow.com/questions/39947822/unable-to-retrieve-full-text-of-title-from-jpeg-metadata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!