Package com.drew.imaging
Class ImageMetadataReader
- java.lang.Object
 - 
- com.drew.imaging.ImageMetadataReader
 
 
- 
public class ImageMetadataReader extends java.lang.ObjectReads 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:
AviMetadataReaderfor AVI filesBmpMetadataReaderfor BMP filesFileSystemMetadataReaderfor metadata from the file system when aFileis providedGifMetadataReaderfor GIF filesIcoMetadataReaderfor ICO filesJpegMetadataReaderfor JPEG filesMp4MetadataReaderfor MPEG-4 filesPcxMetadataReaderfor PCX filesPngMetadataReaderfor PNG filesPsdMetadataReaderfor Photoshop filesQuickTimeMetadataReaderfor QuickTime filesRafMetadataReaderfor RAF filesTiffMetadataReaderfor TIFF and (most) RAW filesWavMetadataReaderfor WAV filesWebpMetadataReaderfor WebP files
FileTypeDetectoris 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 voidmain(java.lang.String[] args)An application entry point.static MetadatareadMetadata(java.io.File file)ReadsMetadatafrom aFileobject.static MetadatareadMetadata(java.io.InputStream inputStream)Reads metadata from anInputStream.static MetadatareadMetadata(java.io.InputStream inputStream, long streamLength)Reads metadata from anInputStreamof known length.static MetadatareadMetadata(java.io.InputStream inputStream, long streamLength, FileType fileType)Reads metadata from anInputStreamof 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 
Metadataobject 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 anInputStreamof 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 
Metadataobject 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 anInputStreamof 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 
Metadataobject 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
ReadsMetadatafrom aFileobject.- Parameters:
 file- a file from which the image data may be read.- Returns:
 - a populated 
Metadataobject 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.IOExceptionAn application entry point. Takes the name of one or more files as arguments and prints the contents of all metadata directories toSystem.out.If
-thumbis passed, then any thumbnail data will be written to a file with name of the input file having.thumb.jpgappended.If
-markdownis passed, then output will be in markdown format.If
-hexis passed, then the ID of each tag will be displayed in hexadecimal.- Parameters:
 args- the command line arguments- Throws:
 MetadataExceptionjava.io.IOException
 
 - 
 
 -