Package net.sourceforge.tess4j.util
Class ImageIOHelper
java.lang.Object
net.sourceforge.tess4j.util.ImageIOHelper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteBufferConvertsBufferedImagetoByteBuffer.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 ofIIOImageobjects.createTiffFiles(List<IIOImage> imageList, int index, int dpiX, int dpiY) static FiledeskewImage(File imageFile, double minimumDeskewThreshold) Deskews image.Gets a list ofIIOImageobjects for aBufferedImage.getIIOImageList(File inputFile) Gets a list ofIIOImageobjects for an image file.static ByteBuffergetImageByteBuffer(RenderedImage image) Gets pixel data of anRenderedImageobject.static ByteBuffergetImageByteBuffer(IIOImage image) Gets pixel data of anIIOImageobject.static FilegetImageFile(File inputFile) Gets image file.static StringgetImageFileFormat(File imageFile) Gets image file format.static List<BufferedImage>getImageList(File inputFile) Gets a list ofBufferedImageobjects for an image file.static voidmergeTiff(BufferedImage[] inputImages, File outputTiff) Merges multiple images into one multi-page TIFF image.static voidmergeTiff(BufferedImage[] inputImages, File outputTiff, String compressionType) Merges multiple images into one multi-page TIFF image.static voidMerges multiple images into one multi-page TIFF image.static voidMerges multiple images into one multi-page TIFF image.static voidMerges 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 ofIIOImageobjects.- Parameters:
imageList- a list ofIIOImageobjectsindex- 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 anIIOImageobject.- Parameters:
image- anIIOImageobject- Returns:
- a byte buffer of pixel data
-
getImageByteBuffer
Gets pixel data of anRenderedImageobject.- Parameters:
image- anRenderedImageobject- Returns:
- a byte buffer of pixel data
-
convertImageData
ConvertsBufferedImagetoByteBuffer.- 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 ofBufferedImageobjects 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- Returns:
- a list of
BufferedImageobjects - Throws:
IOException
-
getIIOImageList
Gets a list ofIIOImageobjects 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- Returns:
- a list of
IIOImageobjects - Throws:
IOException
-
getIIOImageList
Gets a list ofIIOImageobjects for aBufferedImage.- Parameters:
bi- input image- Returns:
- a list of
IIOImageobjects - 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 ofBufferedImageoutputTiff- 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 ofBufferedImageoutputTiff- 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 ofIIOImageobjectsoutputTiff- 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 ofIIOImageobjectsoutputTiff- 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
-