Package org.apache.tika.detect.image
Class RawTiffDetector
java.lang.Object
org.apache.tika.detect.image.RawTiffDetector
- All Implemented Interfaces:
Serializable,SelfConfiguring,Detector
Tells the TIFF-based raw camera formats (Nikon NEF/NRW, Pentax PEF/PTX,
Sony ARW/SRF/SR2, Samsung SRW, Adobe DNG) from a plain TIFF by content,
so they are recognized without a file name (TIKA-4861). They share the
TIFF magic; what differs is the image directory:
- a
DNGVersiontag (0xC612) makes a DNG, whoever wrote it; - a vendor-specific
Compressionvalue (0x0103) in any IFD names the format: 34713 Nikon, 32767 Sony, 65535 Pentax, 32770 and 32772 Samsung (this is how ExifTool identifies them); - otherwise sensor data in any IFD marks a raw, and the
Maketag (0x010F) picks the vendor: an image withPhotometricInterpretation32803 (CFA) or 34892 (LinearRaw), or a full-resolution image (NewSubfileType 0) of one 9 to 16 bit sample without any PhotometricInterpretation, which a regular TIFF must have (Samsung NX1). This catches the uncompressed variants. A plain TIFF from the same camera has RGB data and staysimage/tiff.
MAX_PREFIX_LENGTH, and walks the IFD chain and the
SubIFDs (0x014A) inside that prefix; raw files keep their directories
ahead of the sensor data, though behind the embedded previews (some
hundred KB). A plain TIFF with its directory at the start costs a few KB.
Anything it cannot decide is left to the other detectors as
application/octet-stream. Canon CR2 has a fixed signature and is
matched by the mime magic instead.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondetect(TikaInputStream tis, Metadata metadata, ParseContext parseContext) Detects the content type of the given input document.
-
Constructor Details
-
RawTiffDetector
public RawTiffDetector()
-
-
Method Details
-
detect
public MediaType detect(TikaInputStream tis, Metadata metadata, ParseContext parseContext) throws IOException Description copied from interface:DetectorDetects the content type of the given input document. Returnsapplication/octet-streamif the type of the document can not be detected.If the document input stream is not available, then the first argument may be
null. Otherwise the detector may read bytes from the start of the stream to help in type detection. The detector is expected to mark the stream before reading any bytes from it, and to reset the stream before returning. The stream must not be closed by the detector.The given input metadata is only read, not modified, by the detector.
- Specified by:
detectin interfaceDetector- Parameters:
tis- document input stream, ornullmetadata- input metadata for the documentparseContext- the parse context- Returns:
- detected media type, or
application/octet-stream - Throws:
IOException- if the document input stream could not be read
-