ImageExtractor
in package
Extract sub-images from an image.
Table of Contents
Properties
- $inputSource : LocalInputSource
- Local input object used by the ImageExtractor.
- $filename : string
- Name of the file.
- $pageImages : array<string|int, mixed>
- Array of extracted page images.
- $saveFormat : string
- Format to save the image as.
Methods
- __construct() : mixed
- extractImage() : ExtractedImage|null
- 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.
- getInputSource() : LocalInputSource
- Getter for the local input source.
- getPageCount() : int
- Gets the number of pages in the file.
- pdfToImages() : array<string|int, mixed>
- 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
$inputSource
Local input object used by the ImageExtractor.
protected
LocalInputSource
$inputSource
$filename
Name of the file.
private
string
$filename
$pageImages
Array of extracted page images.
private
array<string|int, mixed>
$pageImages
= []
$saveFormat
Format to save the image as.
private
string
$saveFormat
Methods
__construct()
public
__construct(LocalInputSource $localInput[, string|null $saveFormat = null ]) : mixed
Parameters
- $localInput : LocalInputSource
-
Local Input, accepts all compatible formats.
- $saveFormat : string|null = 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) : ExtractedImage|null
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.
Tags
Return values
ExtractedImage|null —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[, string|null $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 : string|null = null
-
The base output filename, must have an image extension.
Return values
array<string|int, mixed> —A list of extracted 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
intpdfToImages()
Renders the input PDF's pages as individual images.
public
static pdfToImages(string $fileBytes) : array<string|int, mixed>
Parameters
- $fileBytes : string
-
Input pdf.
Tags
Return values
array<string|int, mixed> —A list of pages.
extractFromPage()
Extracts images from a page.
private
extractFromPage(array<string|int, mixed> $fields, int $pageIndex, string $outputName) : 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.
Return values
array<string|int, mixed> —An array of created images.
extractImageFromBbox()
Extracts an image from a set of coordinates.
private
extractImageFromBbox(BBox $bbox, int $pageIndex) : Imagick
Parameters
- $bbox : BBox
-
BBox coordinates.
- $pageIndex : int
-
The page index to extract, begins at 0.
Return values
ImagicksplitNameStrict()
Splits the filename into name and extension.
private
splitNameStrict(string $filename) : array<string|int, mixed>
Parameters
- $filename : string
-
Name of the file.