ExtractedImage
in package
An extracted sub-image.
Table of Contents
Properties
- $buffer : string
- $elementId : int
- $filename : string
- $pageId : int
- $saveFormat : string
Methods
- __construct() : mixed
- Initializes a new instance of the ExtractedImage class.
- asInputSource() : BytesInput
- Returns the image in a format suitable for sending to a client for parsing.
- getEncodedImageFormat() : string
- Get the encoded image format, as understood by bernard_ledit.
- writeToFile() : void
- Writes the image to a file.
- writeBytes() : void
- Writes bytes to a file, and fails if they weren't all written.
Properties
$buffer
public
string
$buffer
$elementId
public
int
$elementId
$filename
public
string
$filename
$pageId
public
int
$pageId
$saveFormat
protected
string
$saveFormat
Methods
__construct()
Initializes a new instance of the ExtractedImage class.
public
__construct(string $buffer, string $filename, string $saveFormat, int $pageId, int $elementId) : mixed
Parameters
- $buffer : string
-
The extracted image, encoded in its save format.
- $filename : string
-
The filename for the image.
- $saveFormat : string
-
The format to save the image.
- $pageId : int
-
The page index of the image.
- $elementId : int
-
The element index of the image.
Tags
asInputSource()
Returns the image in a format suitable for sending to a client for parsing.
public
asInputSource() : BytesInput
Return values
BytesInput —Bytes input for the image.
getEncodedImageFormat()
Get the encoded image format, as understood by bernard_ledit.
public
static getEncodedImageFormat(string $saveFormat) : string
Parameters
- $saveFormat : string
-
Format to save the file as.
Return values
string —Encoded image format.
writeToFile()
Writes the image to a file.
public
writeToFile(string $outputPath[, null|string $format = null ][, int|null $quality = null ]) : void
Uses the default image format and filename. The buffer is written as-is unless another format or a quality is requested, in which case it is re-encoded.
Parameters
- $outputPath : string
-
The output directory (must exist).
- $format : null|string = null
-
The image format to use. Defaults to the save format if not provided.
- $quality : int|null = null
-
Quality of the saved image (JPEG only). Re-encodes the image if set.
Tags
writeBytes()
Writes bytes to a file, and fails if they weren't all written.
private
static writeBytes(string $path, string $bytes) : void
Parameters
- $path : string
- $bytes : string