Package com.drew.imaging
Class ImageMetadataReader
- java.lang.Object
-
- com.drew.imaging.ImageMetadataReader
-
public class ImageMetadataReader extends java.lang.Object
Reads metadata from any supported file format.This class a lightweight wrapper around other, specific metadata processors. During extraction, the file type is determined from the first few bytes of the file. Parsing is then delegated to one of:
AviMetadataReader
for AVI filesBmpMetadataReader
for BMP filesFileSystemMetadataReader
for metadata from the file system when aFile
is providedGifMetadataReader
for GIF filesIcoMetadataReader
for ICO filesJpegMetadataReader
for JPEG filesMp4MetadataReader
for MPEG-4 filesPcxMetadataReader
for PCX filesPngMetadataReader
for PNG filesPsdMetadataReader
for Photoshop filesQuickTimeMetadataReader
for QuickTime filesRafMetadataReader
for RAF filesTiffMetadataReader
for TIFF and (most) RAW filesWavMetadataReader
for WAV filesWebpMetadataReader
for WebP files
FileTypeDetector
is used to determine the provided image's file type, and therefore the appropriate metadata reader to use.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
An application entry point.static Metadata
readMetadata(java.io.File file)
ReadsMetadata
from aFile
object.static Metadata
readMetadata(java.io.InputStream inputStream)
Reads metadata from anInputStream
.static Metadata
readMetadata(java.io.InputStream inputStream, long streamLength)
Reads metadata from anInputStream
of known length.static Metadata
readMetadata(java.io.InputStream inputStream, long streamLength, FileType fileType)
Reads metadata from anInputStream
of known length and file type.
-
-
-
Method Detail
-
readMetadata
public static Metadata readMetadata(java.io.InputStream inputStream) throws ImageProcessingException, java.io.IOException
Reads metadata from anInputStream
.- Parameters:
inputStream
- a stream from which the file data may be read. The stream must be positioned at the beginning of the file's data.- Returns:
- a populated
Metadata
object containing directories of tags with values and any processing errors. - Throws:
ImageProcessingException
- if the file type is unknown, or for general processing errors.java.io.IOException
-
readMetadata
public static Metadata readMetadata(java.io.InputStream inputStream, long streamLength) throws ImageProcessingException, java.io.IOException
Reads metadata from anInputStream
of known length.- Parameters:
inputStream
- a stream from which the file data may be read. The stream must be positioned at the beginning of the file's data.streamLength
- the length of the stream, if known, otherwise -1.- Returns:
- a populated
Metadata
object containing directories of tags with values and any processing errors. - Throws:
ImageProcessingException
- if the file type is unknown, or for general processing errors.java.io.IOException
-
readMetadata
public static Metadata readMetadata(java.io.InputStream inputStream, long streamLength, FileType fileType) throws java.io.IOException, ImageProcessingException
Reads metadata from anInputStream
of known length and file type.- Parameters:
inputStream
- a stream from which the file data may be read. The stream must be positioned at the beginning of the file's data.streamLength
- the length of the stream, if known, otherwise -1.fileType
- the file type of the data stream.- Returns:
- a populated
Metadata
object containing directories of tags with values and any processing errors. - Throws:
ImageProcessingException
- if the file type is unknown, or for general processing errors.java.io.IOException
-
readMetadata
public static Metadata readMetadata(java.io.File file) throws ImageProcessingException, java.io.IOException
ReadsMetadata
from aFile
object.- Parameters:
file
- a file from which the image data may be read.- Returns:
- a populated
Metadata
object containing directories of tags with values and any processing errors. - Throws:
ImageProcessingException
- for general processing errors.java.io.IOException
-
main
public static void main(java.lang.String[] args) throws MetadataException, java.io.IOException
An application entry point. Takes the name of one or more files as arguments and prints the contents of all metadata directories toSystem.out
.If
-thumb
is passed, then any thumbnail data will be written to a file with name of the input file having.thumb.jpg
appended.If
-markdown
is passed, then output will be in markdown format.If
-hex
is passed, then the ID of each tag will be displayed in hexadecimal.- Parameters:
args
- the command line arguments- Throws:
MetadataException
java.io.IOException
-
-