Rundiz\Image

Save extends AbstractGdCommand
in package
uses GdTrait

Save command class.

Tags
since
3.1.0

Table of Contents

Properties

$Gd  : Gd

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

Methods

execute()

Execute the command.

public execute(mixed $file_name) : bool
Parameters
$file_name : mixed
Return values
bool

fillTransparentOnObject()

Fill transparent-white on selected image object.

protected fillTransparentOnObject(GdImage|resource $image) : mixed
Parameters
$image : GdImage|resource

Image object to fill color.

Tags
since
3.1.4

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 \GdImage variable to check.

Tags
since
3.0.2

Moved from \Rundiz\Image\Drivers\Gd

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
since
3.1.4
see
AbstractImage::setErrorMessage()
throws
InvalidArgumentException

Throw the exception if argument type is invalid.

setStatusSuccess()

Set status as success and remove error message, error code.

protected setStatusSuccess() : mixed
Tags
since
3.1.4
see
AbstractImage::setStatusSuccess()

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_XXX by PHP. This value may have got from getImageFileData() method.

Tags
since
3.1.4
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.

Tags
since
3.2.0
throws
InvalidArgumentException

Throw exception if provide argument type mismatch.


        
On this page

Search results