Documentation

ImageExtractor
in package

Extract sub-images from an image.

Table of Contents

Properties

$pageCount  : int
$filename  : string
$inputSource  : LocalInputSource
$pageImages  : array<string|int, Imagick>
$saveFormat  : string

Methods

__construct()  : mixed
extractPolygonFromPage()  : ExtractedImage
Extracts a cropped portion from an image.
extractPolygonsFromPage()  : array<string|int, ExtractedImage>
Extracts images from a page.
getInputSource()  : LocalInputSource
Getter for the local input source.
pdfToImages()  : array<string|int, Imagick>
Renders the input PDF's pages as individual images.
extractImageFromBbox()  : Imagick
Extracts an image from a set of coordinates.
splitNameStrict()  : array{0: string, 1: string}
Splits the filename into name and extension.

Properties

$pageCount

public int $pageCount

Number of pages in the document.

$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
throws
MindeePdfException

Throws if PDF operations aren't supported, or if the file can't be read, respectively.

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
throws
MindeeImageException

Throws if the image can't be processed.

Return values
ExtractedImage

Extracted image data.

extractPolygonsFromPage()

Extracts images from a page.

public extractPolygonsFromPage(array<string|int, Polygon|array<string|int, Point>> $polygons, int $pageIndex[, null|string $filenamePrefix = null ][, null|string $format = null ]) : array<string|int, ExtractedImage>
Parameters
$polygons : array<string|int, Polygon|array<string|int, Point>>

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
throws
MindeeImageException

Throws if the image can't be processed.

Return values
array<string|int, ExtractedImage>

An array of created images

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
throws
MindeeImageException

Throws if the image can't be handled.

Return values
array<string|int, Imagick>

A list of pages.

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
throws
ImagickException

Throws if the image can't be processed.

Return values
Imagick

splitNameStrict()

Splits the filename into name and extension.

protected static splitNameStrict(string $filename) : array{0: string, 1: string}
Parameters
$filename : string

Name of the file.

Return values
array{0: string, 1: string}

An array containing the name and extension of the file.

On this page

Search results