Package gov.nih.mipav.model.file
Class MetadataExtractor.JpegSegmentReader
java.lang.Object
gov.nih.mipav.model.file.MetadataExtractor.JpegSegmentReader
- Enclosing class:
MetadataExtractor
Performs read functions of JPEG files, returning specific file segments.
JPEG files are composed of a sequence of consecutive JPEG 'segments'. Each is identified by one of a set of byte
values, modelled in the MetadataExtractor.JpegSegmentType enumeration. Use readSegments to read out the some
or all segments into a MetadataExtractor.JpegSegmentData object, from which the raw JPEG segment byte arrays may be accessed.
- Author:
- Drew Noakes https://drewnoakes.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final bytePrivate, because one wouldn't search for it.private static final byteThe 0xFF byte that signals the start of a segment.private static final bytePrivate, because this segment crashes my algorithm, and searching for it doesn't work (yet). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreadSegments(MetadataExtractor.SequentialReader reader, Iterable<MetadataExtractor.JpegSegmentType> segmentTypes) Processes the provided JPEG data, and extracts the specified JPEG segments into aMetadataExtractor.JpegSegmentDataobject.readSegments(File file, Iterable<MetadataExtractor.JpegSegmentType> segmentTypes) Processes the provided JPEG data, and extracts the specified JPEG segments into aMetadataExtractor.JpegSegmentDataobject.
-
Field Details
-
SEGMENT_IDENTIFIER
private static final byte SEGMENT_IDENTIFIERThe 0xFF byte that signals the start of a segment.- See Also:
-
SEGMENT_SOS
private static final byte SEGMENT_SOSPrivate, because this segment crashes my algorithm, and searching for it doesn't work (yet).- See Also:
-
MARKER_EOI
private static final byte MARKER_EOIPrivate, because one wouldn't search for it.- See Also:
-
-
Constructor Details
-
JpegSegmentReader
- Throws:
Exception
-
-
Method Details
-
readSegments
public static MetadataExtractor.JpegSegmentData readSegments(File file, Iterable<MetadataExtractor.JpegSegmentType> segmentTypes) throws MetadataExtractor.JpegProcessingException, IOException Processes the provided JPEG data, and extracts the specified JPEG segments into aMetadataExtractor.JpegSegmentDataobject.Will not return SOS (start of scan) or EOI (end of image) segments.
- Parameters:
file- aFilefrom which the JPEG data will be read.segmentTypes- the set of JPEG segments types that are to be returned. If this argument isnullthen all found segment types are returned.- Throws:
MetadataExtractor.JpegProcessingExceptionIOException
-
readSegments
public static MetadataExtractor.JpegSegmentData readSegments(MetadataExtractor.SequentialReader reader, Iterable<MetadataExtractor.JpegSegmentType> segmentTypes) throws MetadataExtractor.JpegProcessingException, IOException Processes the provided JPEG data, and extracts the specified JPEG segments into aMetadataExtractor.JpegSegmentDataobject.Will not return SOS (start of scan) or EOI (end of image) segments.
- Parameters:
reader- aMetadataExtractor.SequentialReaderfrom which the JPEG data will be read. It must be positioned at the beginning of the JPEG data stream.segmentTypes- the set of JPEG segments types that are to be returned. If this argument isnullthen all found segment types are returned.- Throws:
MetadataExtractor.JpegProcessingExceptionIOException
-