Rotate
extends AbstractGdCommand
in package
uses
GdTrait, ImageTrait
Rotate
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- execute() : bool
- Execute the command.
- getImageFileData() : array<string|int, mixed>|false
- Get image file data such as width, height, mime type, extension.
- 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.
- normalizeDegree() : int|string
- Normalize degree.
- normalizeWidthHeight() : array<string|int, mixed>
- Convert width, height to integer and check if it is less than 0 then set to minimum value.
- 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.
- verifyQualityValue() : mixed
- Verify image save quality value.
- getImageColorAlpha() : mixed
- Get image color with alpha value (transparency).
- normalizeWatermarkOptions() : void
- Normalize watermark options.
Properties
$Gd
protected
Gd
$Gd
Methods
__construct()
public
__construct(Gd $Gd) : mixed
Parameters
- $Gd : Gd
execute()
Execute the command.
public
execute([mixed $degree = 90 ]) : bool
Parameters
- $degree : mixed = 90
Return values
boolgetImageFileData()
Get image file data such as width, height, mime type, extension.
public
getImageFileData(string $imagePath) : array<string|int, mixed>|false
This will be use getimagesize() function if supported, something else as backup.
Parameters
- $imagePath : string
-
Full path to image file.
Tags
Return values
array<string|int, mixed>|false —Return array:
index 0 Image width.
index 1 Image height.
index 2 Image type constant. See more at https://www.php.net/manual/en/image.constants.php
mime key is mime type.
ext key is file extension with dot (.ext).
Other array keys are optional, it can be omit.
Return false on failure.
fillTransparentOnObject()
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.
normalizeDegree()
Normalize degree.
protected
normalizeDegree(int|string $degree) : int|string
If degree is allowed string then it will be return as-is. If degree is number then it will be convert to integer.
Parameters
- $degree : int|string
-
The degree.
Return values
int|string —Return converted degree.
normalizeWidthHeight()
Convert width, height to integer and check if it is less than 0 then set to minimum value.
protected
normalizeWidthHeight(int $width, int $height[, int|false $minWidth = 100 ][, int|false $minHeight = 100 ]) : array<string|int, mixed>
Parameters
- $width : int
-
Width
- $height : int
-
Height
- $minWidth : int|false = 100
-
Minimum that width must not less than 0. Set to
falseto not check it. Default is 100. - $minHeight : int|false = 100
-
Minimum that height must not less than 0. Set to
falseto not check it. Default is 100.
Return values
array<string|int, mixed> —Return 2D array where first index is width, second index is height.
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.
verifyQualityValue()
Verify image save quality value.
protected
verifyQualityValue() : mixed
Tags
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
normalizeWatermarkOptions()
Normalize watermark options.
private
normalizeWatermarkOptions(array<string|int, mixed> &$options) : void
Parameters
- $options : array<string|int, mixed>
-
The watermark options to be altered.