Package org.apache.tika.parser.enricher
Class ImageProbe
java.lang.Object
org.apache.tika.parser.enricher.ImageProbe
What the checks of one image share: its bytes, read once and left in the stream for the
engine, the dimensions its parser recorded, and anything a check chooses to memoize, so two checks that need the decoded pixels decode them once.
- Since:
- Apache Tika 4.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA computation that may fail to read. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intHow much of the start of an imageheader()reads: enough for a header.static final intImages longer than this are not read for a check; the checks then admit them. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]bytes()The image's bytes, read on first use and left in the stream, or null when it is longer thanMAX_BYTESor cannot be read.byte[]header()The firstHEADER_BYTESof the image (all of it when it is shorter), read on first use and left in the stream: enough for a check that needs only dimensions, so a large image is not read whole for it.booleanWhetherheader()is the whole image.longlength()The image's length in bytes without reading it, or -1 when the stream does not know it or knows only a declared length (a container's or a header's), which may lie.<T> Tmemo(String key, ImageProbe.Computation<T> computation) A value one check computes and the next reuses; computed once per key.The height the image's parser recorded (tiff:ImageLength), or null.The width the image's parser recorded (tiff:ImageWidth), or null.
-
Field Details
-
MAX_BYTES
public static final int MAX_BYTESImages longer than this are not read for a check; the checks then admit them.- See Also:
-
HEADER_BYTES
public static final int HEADER_BYTESHow much of the start of an imageheader()reads: enough for a header.- See Also:
-
-
Constructor Details
-
ImageProbe
-
-
Method Details
-
recordedWidth
The width the image's parser recorded (tiff:ImageWidth), or null. -
recordedHeight
The height the image's parser recorded (tiff:ImageLength), or null. -
length
The image's length in bytes without reading it, or -1 when the stream does not know it or knows only a declared length (a container's or a header's), which may lie.- Throws:
IOException
-
header
The firstHEADER_BYTESof the image (all of it when it is shorter), read on first use and left in the stream: enough for a check that needs only dimensions, so a large image is not read whole for it. Treat the array as read-only.- Throws:
IOException
-
headerIsComplete
Whetherheader()is the whole image.- Throws:
IOException
-
bytes
The image's bytes, read on first use and left in the stream, or null when it is longer thanMAX_BYTESor cannot be read. Treat the array as read-only.- Throws:
IOException
-
memo
A value one check computes and the next reuses; computed once per key.- Throws:
IOException
-