Class XmpReader
- java.lang.Object
-
- com.drew.metadata.xmp.XmpReader
-
- All Implemented Interfaces:
JpegSegmentMetadataReader
public class XmpReader extends java.lang.Object implements JpegSegmentMetadataReader
Extracts XMP data from JPEG APP1 segments.Note that XMP uses a namespace and path format for identifying values, which does not map to metadata-extractor's integer based tag identifiers. Therefore, XMP data is extracted and exposed via
XmpDirectory.getXMPMeta()which returns an instance of Adobe'sXMPMetawhich exposes the full XMP data set.The extraction is done with Adobe's XmpCore-Library (XMP-Toolkit) Copyright (c) 1999 - 2007, Adobe Systems Incorporated All rights reserved.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringATTRIBUTE_EXTENDED_XMPprivate static intEXTENDED_XMP_GUID_LENGTHExtended XMP constantsprivate static intEXTENDED_XMP_INT_LENGTHprivate static com.adobe.internal.xmp.options.ParseOptionsPARSE_OPTIONSprivate static java.lang.StringSCHEMA_XMP_NOTESprivate static java.lang.StringXMP_EXTENSION_JPEG_PREAMBLEprivate static java.lang.StringXMP_JPEG_PREAMBLE
-
Constructor Summary
Constructors Constructor Description XmpReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidextract(byte[] xmpBytes, int offset, int length, Metadata metadata, Directory parentDirectory)Performs the XMP data extraction, adding found values to the specified instance ofMetadata.voidextract(byte[] xmpBytes, Metadata metadata)Performs the XMP data extraction, adding found values to the specified instance ofMetadata.voidextract(byte[] xmpBytes, Metadata metadata, Directory parentDirectory)Performs the XMP data extraction, adding found values to the specified instance ofMetadata.voidextract(StringValue xmpString, Metadata metadata)Performs the XMP data extraction, adding found values to the specified instance ofMetadata.voidextract(java.lang.String xmpString, Metadata metadata)Performs the XMP data extraction, adding found values to the specified instance ofMetadata.voidextract(java.lang.String xmpString, Metadata metadata, Directory parentDirectory)Performs the XMP data extraction, adding found values to the specified instance ofMetadata.private static java.lang.StringgetExtendedXMPGUID(Metadata metadata)Determine if there is an extended XMP section based on the standard XMP part.java.lang.Iterable<JpegSegmentType>getSegmentTypes()Gets the set of JPEG segment types that this reader is interested in.private static byte[]processExtendedXMPChunk(Metadata metadata, byte[] segmentBytes, java.lang.String extendedXMPGUID, byte[] extendedXMPBuffer)Process an Extended XMP chunk.voidreadJpegSegments(java.lang.Iterable<byte[]> segments, Metadata metadata, JpegSegmentType segmentType)Version specifically for dealing with XMP found in JPEG segments.
-
-
-
Field Detail
-
XMP_JPEG_PREAMBLE
private static final java.lang.String XMP_JPEG_PREAMBLE
- See Also:
- Constant Field Values
-
XMP_EXTENSION_JPEG_PREAMBLE
private static final java.lang.String XMP_EXTENSION_JPEG_PREAMBLE
- See Also:
- Constant Field Values
-
SCHEMA_XMP_NOTES
private static final java.lang.String SCHEMA_XMP_NOTES
- See Also:
- Constant Field Values
-
ATTRIBUTE_EXTENDED_XMP
private static final java.lang.String ATTRIBUTE_EXTENDED_XMP
- See Also:
- Constant Field Values
-
PARSE_OPTIONS
private static final com.adobe.internal.xmp.options.ParseOptions PARSE_OPTIONS
-
EXTENDED_XMP_GUID_LENGTH
private static final int EXTENDED_XMP_GUID_LENGTH
Extended XMP constants- See Also:
- Constant Field Values
-
EXTENDED_XMP_INT_LENGTH
private static final int EXTENDED_XMP_INT_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSegmentTypes
public java.lang.Iterable<JpegSegmentType> getSegmentTypes()
Description copied from interface:JpegSegmentMetadataReaderGets the set of JPEG segment types that this reader is interested in.- Specified by:
getSegmentTypesin interfaceJpegSegmentMetadataReader
-
readJpegSegments
public void readJpegSegments(java.lang.Iterable<byte[]> segments, Metadata metadata, JpegSegmentType segmentType)Version specifically for dealing with XMP found in JPEG segments. This form of XMP has a peculiar preamble, which must be removed before parsing the XML.- Specified by:
readJpegSegmentsin interfaceJpegSegmentMetadataReader- Parameters:
segments- The byte array from which the metadata should be extracted.metadata- TheMetadataobject into which extracted values should be merged.segmentType- TheJpegSegmentTypebeing read.
-
extract
public void extract(byte[] xmpBytes, Metadata metadata)Performs the XMP data extraction, adding found values to the specified instance ofMetadata.The extraction is done with Adobe's XMPCore library.
-
extract
public void extract(byte[] xmpBytes, Metadata metadata, Directory parentDirectory)Performs the XMP data extraction, adding found values to the specified instance ofMetadata.The extraction is done with Adobe's XMPCore library.
-
extract
public void extract(byte[] xmpBytes, int offset, int length, Metadata metadata, Directory parentDirectory)Performs the XMP data extraction, adding found values to the specified instance ofMetadata.The extraction is done with Adobe's XMPCore library.
-
extract
public void extract(java.lang.String xmpString, Metadata metadata)Performs the XMP data extraction, adding found values to the specified instance ofMetadata.The extraction is done with Adobe's XMPCore library.
-
extract
public void extract(StringValue xmpString, Metadata metadata)
Performs the XMP data extraction, adding found values to the specified instance ofMetadata.The extraction is done with Adobe's XMPCore library.
-
extract
public void extract(java.lang.String xmpString, Metadata metadata, Directory parentDirectory)Performs the XMP data extraction, adding found values to the specified instance ofMetadata.The extraction is done with Adobe's XMPCore library.
-
getExtendedXMPGUID
private static java.lang.String getExtendedXMPGUID(Metadata metadata)
Determine if there is an extended XMP section based on the standard XMP part. The xmpNote:HasExtendedXMP attribute contains the GUID of the Extended XMP chunks.
-
processExtendedXMPChunk
private static byte[] processExtendedXMPChunk(Metadata metadata, byte[] segmentBytes, java.lang.String extendedXMPGUID, byte[] extendedXMPBuffer)
Process an Extended XMP chunk. It will read the bytes from segmentBytes and validates that the GUID the requested one. It will progressively fill the buffer with each chunk. The format is specified in this document: http://www.adobe.com/content/dam/Adobe/en/devnet/xmp/pdfs/XMPSpecificationPart3.pdf at page 19
-
-