Package net.sourceforge.tess4j.util
Class ImageIOHelper
java.lang.Object
net.sourceforge.tess4j.util.ImageIOHelper
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ByteBuffer
ConvertsBufferedImage
toByteBuffer
.createTiffFiles
(File imageFile, int index) Creates a list of TIFF image files from an image file.createTiffFiles
(File imageFile, int index, boolean preserve) Creates a list of TIFF image files from an image file.createTiffFiles
(List<IIOImage> imageList, int index) Creates a list of TIFF image files from a list ofIIOImage
objects.createTiffFiles
(List<IIOImage> imageList, int index, int dpiX, int dpiY) static File
deskewImage
(File imageFile, double minimumDeskewThreshold) Deskews image.Gets a list ofIIOImage
objects for aBufferedImage
.getIIOImageList
(File inputFile) Gets a list ofIIOImage
objects for an image file.static ByteBuffer
getImageByteBuffer
(RenderedImage image) Gets pixel data of anRenderedImage
object.static ByteBuffer
getImageByteBuffer
(IIOImage image) Gets pixel data of anIIOImage
object.static File
getImageFile
(File inputFile) Gets image file.static String
getImageFileFormat
(File imageFile) Gets image file format.static List<BufferedImage>
getImageList
(File inputFile) Gets a list ofBufferedImage
objects for an image file.static void
mergeTiff
(BufferedImage[] inputImages, File outputTiff) Merges multiple images into one multi-page TIFF image.static void
mergeTiff
(BufferedImage[] inputImages, File outputTiff, String compressionType) Merges multiple images into one multi-page TIFF image.static void
Merges multiple images into one multi-page TIFF image.static void
Merges multiple images into one multi-page TIFF image.static void
Merges multiple images into one multi-page TIFF image.readImageData
(IIOImage oimage) Reads image meta data.
-
Field Details
-
TIFF_EXT
- See Also:
-
JAI_IMAGE_WRITER_MESSAGE
- See Also:
-
JAI_IMAGE_READER_MESSAGE
- See Also:
-
-
Constructor Details
-
ImageIOHelper
public ImageIOHelper()
-
-
Method Details
-
createTiffFiles
Creates a list of TIFF image files from an image file. It basically converts images of other formats to TIFF format, or a multi-page TIFF image to multiple TIFF image files.- Parameters:
imageFile
- input image fileindex
- an index of the page; -1 means all pages, as in a multi-page TIFF image- Returns:
- a list of TIFF image files
- Throws:
IOException
-
createTiffFiles
public static List<File> createTiffFiles(File imageFile, int index, boolean preserve) throws IOException Creates a list of TIFF image files from an image file. It basically converts images of other formats to TIFF format, or a multi-page TIFF image to multiple TIFF image files.- Parameters:
imageFile
- input image fileindex
- an index of the page; -1 means all pages, as in a multi-page TIFF imagepreserve
- preserve compression mode- Returns:
- a list of TIFF image files
- Throws:
IOException
-
createTiffFiles
Creates a list of TIFF image files from a list ofIIOImage
objects.- Parameters:
imageList
- a list ofIIOImage
objectsindex
- an index of the page; -1 means all pages- Returns:
- a list of TIFF image files
- Throws:
IOException
-
createTiffFiles
public static List<File> createTiffFiles(List<IIOImage> imageList, int index, int dpiX, int dpiY) throws IOException - Throws:
IOException
-
getImageByteBuffer
Gets pixel data of anIIOImage
object.- Parameters:
image
- anIIOImage
object- Returns:
- a byte buffer of pixel data
-
getImageByteBuffer
Gets pixel data of anRenderedImage
object.- Parameters:
image
- anRenderedImage
object- Returns:
- a byte buffer of pixel data
-
convertImageData
ConvertsBufferedImage
toByteBuffer
.- Parameters:
bi
- Input image- Returns:
- pixel data
-
getImageFileFormat
Gets image file format.- Parameters:
imageFile
- input image file- Returns:
- image file format
-
getImageFile
Gets image file. Convert to multi-page TIFF if given PDF.- Parameters:
inputFile
- input file (common image or PDF)- Returns:
- image file
- Throws:
IOException
-
getImageList
Gets a list ofBufferedImage
objects for an image file.- Parameters:
inputFile
- input image file. It can be any of the supported formats, including TIFF, JPEG, GIF, PNG, BMP, JPEG, and PDF if GPL Ghostscript or PDFBox is installed- Returns:
- a list of
BufferedImage
objects - Throws:
IOException
-
getIIOImageList
Gets a list ofIIOImage
objects for an image file.- Parameters:
inputFile
- input image file. It can be any of the supported formats, including TIFF, JPEG, GIF, PNG, BMP, JPEG, and PDF if GPL Ghostscript or PDFBox is installed- Returns:
- a list of
IIOImage
objects - Throws:
IOException
-
getIIOImageList
Gets a list ofIIOImage
objects for aBufferedImage
.- Parameters:
bi
- input image- Returns:
- a list of
IIOImage
objects - Throws:
IOException
-
mergeTiff
Merges multiple images into one multi-page TIFF image.- Parameters:
inputImages
- an array of image filesoutputTiff
- the output multi-page TIFF file- Throws:
IOException
-
mergeTiff
Merges multiple images into one multi-page TIFF image.- Parameters:
inputImages
- an array ofBufferedImage
outputTiff
- the output TIFF file- Throws:
IOException
-
mergeTiff
public static void mergeTiff(BufferedImage[] inputImages, File outputTiff, String compressionType) throws IOException Merges multiple images into one multi-page TIFF image.- Parameters:
inputImages
- an array ofBufferedImage
outputTiff
- the output TIFF filecompressionType
- valid values: LZW, CCITT T.6, PackBits- Throws:
IOException
-
mergeTiff
Merges multiple images into one multi-page TIFF image.- Parameters:
imageList
- a list ofIIOImage
objectsoutputTiff
- the output TIFF file- Throws:
IOException
-
mergeTiff
public static void mergeTiff(List<IIOImage> imageList, File outputTiff, String compressionType) throws IOException Merges multiple images into one multi-page TIFF image.- Parameters:
imageList
- a list ofIIOImage
objectsoutputTiff
- the output TIFF filecompressionType
- valid values: LZW, CCITT T.6, PackBits- Throws:
IOException
-
deskewImage
Deskews image.- Parameters:
imageFile
- input imageminimumDeskewThreshold
- minimum deskew threshold (typically, 0.05d)- Returns:
- temporary multi-page TIFF image file
- Throws:
IOException
-
readImageData
Reads image meta data.- Parameters:
oimage
-- Returns:
- a map of meta data
-