Package com.itextpdf.io.image
Class ImageTypeDetector
- java.lang.Object
-
- com.itextpdf.io.image.ImageTypeDetector
-
public final class ImageTypeDetector extends java.lang.Object
Helper class that detects image type by magic bytes
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]
bmp
private static byte[]
gif
private static byte[]
jbig2
private static byte[]
jpeg
private static byte[]
jpeg2000_1
private static byte[]
jpeg2000_2
private static byte[]
png
private static byte[]
tiff_1
private static byte[]
tiff_2
private static byte[]
wmf
-
Constructor Summary
Constructors Modifier Constructor Description private
ImageTypeDetector()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ImageType
detectImageType(byte[] source)
Detect image type by magic bytes given the byte array source.static ImageType
detectImageType(java.io.InputStream stream)
Detect image type by magic bytes given the input stream.static ImageType
detectImageType(java.net.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(java.io.InputStream stream)
private static byte[]
readImageType(java.net.URL source)
-
-
-
Field Detail
-
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
-
-
Method Detail
-
detectImageType
public static ImageType detectImageType(byte[] source)
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
public static ImageType detectImageType(java.net.URL source)
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
public static ImageType detectImageType(java.io.InputStream stream)
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
private static ImageType detectImageTypeByHeader(byte[] header)
-
imageTypeIs
private static boolean imageTypeIs(byte[] imageType, byte[] compareWith)
-
readImageType
private static byte[] readImageType(java.net.URL source)
-
readImageType
private static byte[] readImageType(java.io.InputStream stream)
-
readImageType
private static byte[] readImageType(byte[] source)
-
-