public class ReadMetadataUtilities extends Object
Metadata
.Modifier and Type | Method and Description |
---|---|
static <T extends com.drew.metadata.Directory> |
findDirectoryWithName(com.drew.metadata.Metadata metadata,
Class<T> directoryType,
String directoryName)
Finds the first
Directory in the metadata with type directoryType and whose
name is equal to directoryName . |
static Optional<Date> |
readDate(com.drew.metadata.Directory directory,
int tag)
Reads a metadata entry of type
Date from a Directory . |
static <T extends com.drew.metadata.Directory> |
readDate(com.drew.metadata.Metadata metadata,
Class<T> directoryType,
int[] tagsAcqusitionDate,
int[] tagsTimezoneOffset)
Reads a metadata entry of type
Date from the first directory of type directoryType . |
static Optional<Extent> |
readFromWidthHeightTags(com.drew.metadata.Directory directory,
int tagWidth,
int tagHeight)
Reads two metadata entries, representing width and height, and use them to form a
Extent . |
static <T extends com.drew.metadata.Directory> |
readFromWidthHeightTags(com.drew.metadata.Metadata metadata,
Class<T> directoryType,
int tagWidth,
int tagHeight)
Reads two metadata entries, representing width and height, and use them to form a
Extent . |
static Optional<Integer> |
readInt(com.drew.metadata.Directory directory,
int tag)
Reads a metadata entry of type
int from a Directory . |
static <T extends com.drew.metadata.Directory> |
readInt(com.drew.metadata.Metadata metadata,
Class<T> directoryType,
int tag)
Reads a metadata entry of type
int from the first directory of type directoryType . |
static Optional<com.drew.metadata.Metadata> |
readMetadata(Path path)
Reads metadata, if it exists, from an image.
|
public static Optional<com.drew.metadata.Metadata> readMetadata(Path path) throws ImageIOException
path
- the path to the image.ImageIOException
- if something goes wrong processing the metadata.public static <T extends com.drew.metadata.Directory> Optional<com.drew.metadata.Directory> findDirectoryWithName(com.drew.metadata.Metadata metadata, Class<T> directoryType, String directoryName)
Directory
in the metadata with type directoryType
and whose
name is equal to directoryName
.T
- directory-type to findmetadata
- the metadata to read from.directoryType
- class corresponding to T
.directoryName
- the name of the directory, which must match, case insensitive.public static <T extends com.drew.metadata.Directory> Optional<Integer> readInt(com.drew.metadata.Metadata metadata, Class<T> directoryType, int tag)
int
from the first directory of type directoryType
.T
- directory-type to findmetadata
- the metadata to read from.directoryType
- class corresponding to T
.tag
- a unique identifier from the metadata-extractor library identifying which tag to
read.Optional.empty()
if it does not exist.public static <T extends com.drew.metadata.Directory> Optional<java.time.ZonedDateTime> readDate(com.drew.metadata.Metadata metadata, Class<T> directoryType, int[] tagsAcqusitionDate, int[] tagsTimezoneOffset)
Date
from the first directory of type directoryType
.
If no timezone offset is specified in the metadata, the current time-zone is used.
T
- directory-type to findmetadata
- the metadata to read from.directoryType
- class corresponding to T
.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 to tagsAcqusitionDate
but instead identifies a
time-zone offset.Optional.empty()
if it does not exist.public static Optional<Integer> readInt(com.drew.metadata.Directory directory, int tag)
int
from a Directory
.directory
- the directory to read from.tag
- a unique identifier from the metadata-extractor library identifying which tag to
read.Optional.empty()
if it does not exist.public static Optional<Date> readDate(com.drew.metadata.Directory directory, int tag)
Date
from a Directory
.directory
- the directory to read from.tag
- a unique identifier from the metadata-extractor library identifying which tag to
read.Optional.empty()
if it does not exist.public static <T extends com.drew.metadata.Directory> Optional<Extent> readFromWidthHeightTags(com.drew.metadata.Metadata metadata, Class<T> directoryType, int tagWidth, int tagHeight) throws ImageIOException
Extent
.
The first directory of type directoryType
is used for the tags.
T
- directory-type to findmetadata
- the metadata to read from.directoryType
- class corresponding to T
.tagWidth
- a unique identifier from the metadata-extractor library identifying the
width tag.tagHeight
- a unique identifier from the metadata-extractor library identifying the
height tag.Optional.empty()
if it does not exist.ImageIOException
- if the metadata is errored (but not if it is absent).public static Optional<Extent> readFromWidthHeightTags(com.drew.metadata.Directory directory, int tagWidth, int tagHeight) throws ImageIOException
Extent
.directory
- the directory to read tags from.tagWidth
- a unique identifier from the metadata-extractor library identifying the
width tag.tagHeight
- a unique identifier from the metadata-extractor library identifying the
height tag.Optional.empty()
if it does not exist.ImageIOException
- if the metadata is errored (but not if it is absent).Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.