ImageExtractor
extends ImageExtractor
in package
Wrapper class for V1 of the BaseImageExtractor.
Table of Contents
Properties
- $filename : string
- $inputSource : LocalInputSource
- $pageImages : array<string|int, Imagick>
- $saveFormat : string
Methods
- __construct() : mixed
- extractImage() : null|ExtractedImage
- Extracts a single image from a Position field.
- extractImagesFromPage() : array<string|int, mixed>
- Extract multiple images on a given page from a list of fields having position data.
- extractPolygonFromPage() : ExtractedImage
- Extracts a cropped portion from an image.
- extractPolygonsFromPage() : array<string|int, mixed>
- Extracts images from a page.
- getInputSource() : LocalInputSource
- Getter for the local input source.
- getPageCount() : int
- Gets the number of pages in the file.
- pdfToImages() : array<string|int, Imagick>
- Renders the input PDF's pages as individual images.
- extractFromPage() : array<string|int, mixed>
- Extracts images from a page.
- extractImageFromBbox() : Imagick
- Extracts an image from a set of coordinates.
- splitNameStrict() : array<string|int, mixed>
- Splits the filename into name and extension.
Properties
$filename
protected
string
$filename
Name of the file.
$inputSource
protected
LocalInputSource
$inputSource
Local input object used by the ImageExtractor.
$pageImages
protected
array<string|int, Imagick>
$pageImages
= []
Array of extracted page images.
$saveFormat
protected
string
$saveFormat
Format to save the image as.
Methods
__construct()
public
__construct(LocalInputSource $localInput[, null|string $saveFormat = null ]) : mixed
Parameters
- $localInput : LocalInputSource
-
Local input, accepts all compatible formats.
- $saveFormat : null|string = null
-
Save format, will be coerced to jpg by default.
Tags
extractImage()
Extracts a single image from a Position field.
public
extractImage(BaseField $field, int $pageIndex, int $index, string $filename, string $format) : null|ExtractedImage
Parameters
- $field : BaseField
-
The field to extract.
- $pageIndex : int
-
The page index to extract, begins at 0.
- $index : int
-
The index to use for naming the extracted image.
- $filename : string
-
The output filename.
- $format : string
-
The output format.
Tags
Return values
null|ExtractedImage —The extracted image, or null if the field does not have valid position data.
extractImagesFromPage()
Extract multiple images on a given page from a list of fields having position data.
public
extractImagesFromPage(array<string|int, mixed> $fields, int $pageIndex[, null|string $outputName = null ]) : array<string|int, mixed>
Parameters
- $fields : array<string|int, mixed>
-
List of Fields to extract.
- $pageIndex : int
-
The page index to extract, begins at 0.
- $outputName : null|string = null
-
The base output filename, must have an image extension.
Return values
array<string|int, mixed> —a list of extracted images
extractPolygonFromPage()
Extracts a cropped portion from an image.
public
extractPolygonFromPage(Polygon $polygon, int $pageIndex, int $index[, null|string $filename = null ][, null|string $format = null ]) : ExtractedImage
Parameters
- $polygon : Polygon
-
Polygon to extract.
- $pageIndex : int
-
Page index to extract from.
- $index : int
-
Index to use for naming the extracted image.
- $filename : null|string = null
-
Output filename.
- $format : null|string = null
-
Output format.
Tags
Return values
ExtractedImage —Extracted image data.
extractPolygonsFromPage()
Extracts images from a page.
public
extractPolygonsFromPage(array<string|int, mixed> $polygons, int $pageIndex[, null|string $filenamePrefix = null ][, null|string $format = null ]) : array<string|int, mixed>
Parameters
- $polygons : array<string|int, mixed>
-
List of polygons to extract.
- $pageIndex : int
-
The page index to extract, begins at 0.
- $filenamePrefix : null|string = null
-
Output filename prefix.
- $format : null|string = null
-
Save format for extracted images. Defaults to the original format.
Tags
Return values
array<string|int, mixed> —an array of created images
getInputSource()
Getter for the local input source.
public
getInputSource() : LocalInputSource
Return values
LocalInputSourcegetPageCount()
Gets the number of pages in the file.
public
getPageCount() : int
Return values
int —Page count.
pdfToImages()
Renders the input PDF's pages as individual images.
public
static pdfToImages(string $fileBytes) : array<string|int, Imagick>
Parameters
- $fileBytes : string
-
Input pdf.
Tags
Return values
array<string|int, Imagick> —A list of pages.
extractFromPage()
Extracts images from a page.
protected
extractFromPage(array<string|int, mixed> $fields, int $pageIndex, string $outputName[, string $format = 'jpg' ]) : array<string|int, mixed>
Parameters
- $fields : array<string|int, mixed>
-
List of Fields to extract.
- $pageIndex : int
-
The page index to extract, begins at 0.
- $outputName : string
-
Name of the created file.
- $format : string = 'jpg'
-
The output format.
Return values
array<string|int, mixed> —an array of created images
extractImageFromBbox()
Extracts an image from a set of coordinates.
protected
extractImageFromBbox(BBox $bbox, int|float $pageIndex) : Imagick
Parameters
- $bbox : BBox
-
BBox coordinates.
- $pageIndex : int|float
-
The page index to extract, begins at 0.
Tags
Return values
ImagicksplitNameStrict()
Splits the filename into name and extension.
protected
static splitNameStrict(string $filename) : array<string|int, mixed>
Parameters
- $filename : string
-
Name of the file.
Return values
array<string|int, mixed> —An array containing the name and extension of the file.