Rundiz\Image

Rotate extends AbstractGdCommand
in package
uses GdTrait, ImageTrait

Rotate

Tags
since
3.1.0

Table of Contents

Properties

$Gd  : Gd

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

Methods

execute()

Execute the command.

public execute([mixed $degree = 90 ]) : bool
Parameters
$degree : mixed = 90
Return values
bool

getImageFileData()

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
since
3.1.0
throws
DomainException

Throw the errors if it is an image but current PHP version is not supported.

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
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.

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 false to not check it. Default is 100.

$minHeight : int|false = 100

Minimum that height must not less than 0. Set to false to 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
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.

verifyQualityValue()

Verify image save quality value.

protected verifyQualityValue() : mixed
Tags
since
3.1.5

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.

normalizeWatermarkOptions()

Normalize watermark options.

private normalizeWatermarkOptions(array<string|int, mixed> &$options) : void
Parameters
$options : array<string|int, mixed>

The watermark options to be altered.

Tags
since
3.2.0
see
ImageInterface::watermarkImage()

For reference for options argument.

see
ImageInterface::watermarkText()

For reference for options argument.


        
On this page

Search results