Class ImageExtractor


  • public class ImageExtractor
    extends Object
    Extract sub-images from an image.
    • Method Detail

      • getPDFRasterizer

        protected PDFRasterization getPDFRasterizer()
        Get the PDF rasterization implementation. Override this method to provide custom PDF rasterization handling.
        Returns:
        The PDF rasterization implementation.
      • getPageCount

        public int getPageCount()
        Get the number of pages in the file.
        Returns:
        The number of pages in the file.
      • extractImagesFromPage

        public <FieldT extends PositionDataFieldExtractedImages extractImagesFromPage​(List<FieldT> fields,
                                                                                        int pageId)
        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.
        pageId - The page index to extract, begins at 0.
        Returns:
        A list of ExtractedImage.
      • extractImage

        public <FieldT extends PositionDataFieldExtractedImage extractImage​(FieldT field,
                                                                              int pageId,
                                                                              int elementId,
                                                                              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.
        elementId - The index to use for naming the extracted image.
        filename - Name of the file.
        pageId - The page index to extract, begins at 0.
        Returns:
        The ExtractedImage, or null if the field does not have valid position data.
      • extractImage

        public <FieldT extends PositionDataFieldExtractedImage extractImage​(FieldT field,
                                                                              int pageId,
                                                                              int elementId)
        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.
        elementId - The index to use for naming the extracted image.
        pageId - The 0-based page index to extract.
        Returns:
        The ExtractedImage, or null if the field does not have valid position data.