Save
extends AbstractGdCommand
in package
uses
GdTrait
Save command class.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- execute() : bool
- Execute the command.
- fillTransparentOnObject() : mixed
- Fill transparent-white on selected image object.
- fillWhiteBgOnDestination() : mixed
- Fill white background on destination image object.
- isResourceOrGDObject() : bool
- Check if image variable is resource of GD or is object of `\GdImage` (PHP 8.0) or not.
- setErrorMessage() : mixed
- Set error message and code. This will be set statusXxx properties.
- setStatusSuccess() : mixed
- Set status as success and remove error message, error code.
- setupSourceFromFile() : GdImage|resource|false
- Setup source image object (GD) from file.
- getImageColorAlpha() : mixed
- Get image color with alpha value (transparency).
Properties
$Gd
protected
Gd
$Gd
Methods
__construct()
public
__construct(Gd $Gd) : mixed
Parameters
- $Gd : Gd
execute()
Execute the command.
public
execute(mixed $file_name) : bool
Parameters
- $file_name : mixed
Return values
boolfillTransparentOnObject()
Fill transparent-white on selected image object.
protected
fillTransparentOnObject(GdImage|resource $image) : mixed
Parameters
- $image : GdImage|resource
-
Image object to fill color.
Tags
fillWhiteBgOnDestination()
Fill white background on destination image object.
protected
fillWhiteBgOnDestination() : mixed
Create temporary canvas, fill white background, copy image from "destination image object" to temp canvas, then mark this canvas as "destination image object".
isResourceOrGDObject()
Check if image variable is resource of GD or is object of `\GdImage` (PHP 8.0) or not.
protected
isResourceOrGDObject(mixed $image) : bool
Parameters
- $image : mixed
-
The
\GdImagevariable to check.
Tags
Return values
bool —Return true if it is resource or instance of \GdImage, return false if it is not.
setErrorMessage()
Set error message and code. This will be set statusXxx properties.
protected
setErrorMessage(string $errorMessage, int $errorCode) : mixed
Parameters
- $errorMessage : string
-
The error message.
- $errorCode : int
-
The error code, usually it is class's constant.
Tags
setStatusSuccess()
Set status as success and remove error message, error code.
protected
setStatusSuccess() : mixed
Tags
setupSourceFromFile()
Setup source image object (GD) from file.
protected
setupSourceFromFile(string $file, int $imageType) : GdImage|resource|false
Parameters
- $file : string
-
Source image file path.
- $imageType : int
-
Image type as defined in
IMAGETYPE_XXXby PHP. This value may have got fromgetImageFileData()method.
Tags
Return values
GdImage|resource|false —Return resource or \GdImage (for PHP 8.0+) on success, false on failure.
getImageColorAlpha()
Get image color with alpha value (transparency).
private
getImageColorAlpha(string $colorName, int $alpha, GdImage|resource $image) : mixed
Parameters
- $colorName : string
-
The color name. Supported 'black', 'white', 'red', 'green', 'blue', 'yellow', 'cyan', 'magenta'.
- $alpha : int
-
The alpha value from 0 (no transparent) to 127 (full transparent).
- $image : GdImage|resource
-
The GD image object or resource.