Package com.mindee.extraction
Class ImageExtractor
- java.lang.Object
-
- com.mindee.extraction.ImageExtractor
-
public class ImageExtractor extends Object
Extract sub-images from an image.
-
-
Constructor Summary
Constructors Constructor Description ImageExtractor(LocalInputSource source)Init from aLocalInputSource.ImageExtractor(String filePath)Init from a path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <FieldT extends PositionData>
ExtractedImageextractImage(FieldT field, int pageIndex, int index)Extract a single image from a field having position data.<FieldT extends PositionData>
ExtractedImageextractImage(FieldT field, int pageIndex, int index, String filename)Extract a single image from a field having position data.<FieldT extends PositionData>
List<ExtractedImage>extractImagesFromPage(List<FieldT> fields, int pageIndex)Extract multiple images on a given page from a list of fields having position data.<FieldT extends PositionData>
List<ExtractedImage>extractImagesFromPage(List<FieldT> fields, int pageIndex, String outputName)Extract multiple images on a given page from a list of fields having position data.intgetPageCount()
-
-
-
Constructor Detail
-
ImageExtractor
public ImageExtractor(String filePath) throws IOException
Init from a path.- Parameters:
filePath- Path to the file.- Throws:
IOException- Throws if the file can't be accessed.
-
ImageExtractor
public ImageExtractor(LocalInputSource source) throws IOException
Init from aLocalInputSource.- Parameters:
source- The local source.- Throws:
IOException- Throws if the file can't be accessed.
-
-
Method Detail
-
getPageCount
public int getPageCount()
- Returns:
- The number of pages in the file.
-
extractImagesFromPage
public <FieldT extends PositionData> List<ExtractedImage> extractImagesFromPage(List<FieldT> fields, int pageIndex)
Extract multiple images on a given page from a list of fields having position data.- Type Parameters:
FieldT- Type of field (needs to support positioning data).- Parameters:
fields- List of Fields to extract.pageIndex- The page index to extract, begins at 0.- Returns:
- A list of
ExtractedImage.
-
extractImagesFromPage
public <FieldT extends PositionData> List<ExtractedImage> extractImagesFromPage(List<FieldT> fields, int pageIndex, String outputName)
Extract multiple images on a given page from a list of fields having position data.- Type Parameters:
FieldT- Type of field (needs to support positioning data).- Parameters:
fields- List of Fields to extract.pageIndex- The page index to extract, begins at 0.outputName- The base output filename, must have an image extension.- Returns:
- A list of
ExtractedImage.
-
extractImage
public <FieldT extends PositionData> ExtractedImage extractImage(FieldT field, int pageIndex, int index, String filename)
Extract a single image from a field having position data.- Type Parameters:
FieldT- Type of field (needs to support positioning data).- Parameters:
field- The field to extract.index- The index to use for naming the extracted image.filename- Name of the file.pageIndex- The page index to extract, begins at 0.- Returns:
- The
ExtractedImage, ornullif the field does not have valid position data.
-
extractImage
public <FieldT extends PositionData> ExtractedImage extractImage(FieldT field, int pageIndex, int index)
Extract a single image from a field having position data.- Type Parameters:
FieldT- Type of field (needs to support positioning data).- Parameters:
field- The field to extract.index- The index to use for naming the extracted image.pageIndex- The page index to extract, begins at 0.- Returns:
- The
ExtractedImage, ornullif the field does not have valid position data.
-
-