Package com.itextpdf.io.image
Class ImageTypeDetector
java.lang.Object
com.itextpdf.io.image.ImageTypeDetector
Helper class that detects image type by magic bytes
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ImageType
detectImageType
(byte[] source) Detect image type by magic bytes given the byte array source.static ImageType
detectImageType
(InputStream stream) Detect image type by magic bytes given the input stream.static ImageType
detectImageType
(URL source) Detect image type by magic bytes given the source URL.private static ImageType
detectImageTypeByHeader
(byte[] header) private static boolean
imageTypeIs
(byte[] imageType, byte[] compareWith) private static byte[]
readImageType
(byte[] source) private static byte[]
readImageType
(InputStream stream) private static byte[]
readImageType
(URL source)
-
Field Details
-
gif
private static final byte[] gif -
jpeg
private static final byte[] jpeg -
jpeg2000_1
private static final byte[] jpeg2000_1 -
jpeg2000_2
private static final byte[] jpeg2000_2 -
png
private static final byte[] png -
wmf
private static final byte[] wmf -
bmp
private static final byte[] bmp -
tiff_1
private static final byte[] tiff_1 -
tiff_2
private static final byte[] tiff_2 -
jbig2
private static final byte[] jbig2
-
-
Constructor Details
-
ImageTypeDetector
private ImageTypeDetector()
-
-
Method Details
-
detectImageType
Detect image type by magic bytes given the byte array source.- Parameters:
source
- image bytes- Returns:
- detected image type, see
ImageType
. ReturnsImageType.NONE
if image type is unknown
-
detectImageType
Detect image type by magic bytes given the source URL.- Parameters:
source
- image URL- Returns:
- detected image type, see
ImageType
. ReturnsImageType.NONE
if image type is unknown
-
detectImageType
Detect image type by magic bytes given the input stream.- Parameters:
stream
- image stream- Returns:
- detected image type, see
ImageType
. ReturnsImageType.NONE
if image type is unknown
-
detectImageTypeByHeader
-
imageTypeIs
private static boolean imageTypeIs(byte[] imageType, byte[] compareWith) -
readImageType
-
readImageType
-
readImageType
private static byte[] readImageType(byte[] source)
-