Rundiz\Image

ImageTrait

Image trait.

For use between classes without restriction of protected.

Tags
since
3.1.0

Table of Contents

Methods

getImageFileData()  : array<string|int, mixed>|false
Get image file data such as width, height, mime type, extension.
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.
verifyQualityValue()  : mixed
Verify image save quality value.
normalizeWatermarkOptions()  : void
Normalize watermark options.

Methods

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.

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.

verifyQualityValue()

Verify image save quality value.

protected verifyQualityValue() : mixed
Tags
since
3.1.5

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