Class MetadataReader
Object
MetadataReader
Reads various image properties from tags in
Metadata.- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends com.drew.metadata.Directory>
Optional<com.drew.metadata.Directory> findDirectoryWithName(com.drew.metadata.Metadata metadata, Class<T> directoryType, String directoryName) Finds the firstDirectoryin the metadata with typedirectoryTypeand whose name is equal todirectoryName.readDate(com.drew.metadata.Directory directory, int tag) Reads a metadata entry of typeDatefrom aDirectory.static <T extends com.drew.metadata.Directory>
Optional<ZonedDateTime> readDate(com.drew.metadata.Metadata metadata, Class<T> directoryType, int[] tagsAcqusitionDate, int[] tagsTimezoneOffset) Reads a metadata entry of typeDatefrom the first directory of typedirectoryType.readInt(com.drew.metadata.Directory directory, int tag) Reads a metadata entry of typeintfrom aDirectory.Reads a metadata entry of typeintfrom the first directory of typedirectoryType.static Optional<com.drew.metadata.Metadata> readMetadata(Path path) Reads metadata, if it exists, from an image.
-
Method Details
-
readMetadata
Reads metadata, if it exists, from an image.- Parameters:
path- the path to the image.- Returns:
- the metadata, if it exists.
- Throws:
ImageIOException- if something goes wrong processing the metadata.
-
findDirectoryWithName
public static <T extends com.drew.metadata.Directory> Optional<com.drew.metadata.Directory> findDirectoryWithName(com.drew.metadata.Metadata metadata, Class<T> directoryType, String directoryName) Finds the firstDirectoryin the metadata with typedirectoryTypeand whose name is equal todirectoryName.- Type Parameters:
T- directory-type to find- Parameters:
metadata- the metadata to read from.directoryType- class corresponding toT.directoryName- the name of the directory, which must match, case insensitive.- Returns:
- the first directory that matches, if it exists.
-
readInt
public static <T extends com.drew.metadata.Directory> Optional<Integer> readInt(com.drew.metadata.Metadata metadata, Class<T> directoryType, int tag) Reads a metadata entry of typeintfrom the first directory of typedirectoryType.- Type Parameters:
T- directory-type to find- Parameters:
metadata- the metadata to read from.directoryType- class corresponding toT.tag- a unique identifier from the metadata-extractor library identifying which tag to read.- Returns:
- the value of the tag, or
Optional.empty()if it does not exist.
-
readDate
public static <T extends com.drew.metadata.Directory> Optional<ZonedDateTime> readDate(com.drew.metadata.Metadata metadata, Class<T> directoryType, int[] tagsAcqusitionDate, int[] tagsTimezoneOffset) Reads a metadata entry of typeDatefrom the first directory of typedirectoryType.If no timezone offset is specified in the metadata, the current time-zone is used.
- Type Parameters:
T- directory-type to find- Parameters:
metadata- the metadata to read from.directoryType- class corresponding toT.tagsAcqusitionDate- unique identifiers from the metadata-extractor library identifying which tag(s) to read (in order). Once a single tag is found, no further tags are tried.tagsTimezoneOffset- similar totagsAcqusitionDatebut instead identifies a time-zone offset.- Returns:
- the value of the tag, or
Optional.empty()if it does not exist.
-
readInt
Reads a metadata entry of typeintfrom aDirectory.- Parameters:
directory- the directory to read from.tag- a unique identifier from the metadata-extractor library identifying which tag to read.- Returns:
- the value of the tag, or
Optional.empty()if it does not exist.
-
readDate
Reads a metadata entry of typeDatefrom aDirectory.- Parameters:
directory- the directory to read from.tag- a unique identifier from the metadata-extractor library identifying which tag to read.- Returns:
- the value of the tag, or
Optional.empty()if it does not exist.
-