Phpxforms documentation

Image
in package

AbstractYes

Abstract image processing class for subclasses based on GD or ImageMagick

Tags
author

DaVee

version
0.87dev
license

Lesser General Public License 2.1 or later; see http://www.gnu.org/licenses/lgpl-2.1.html

Table of Contents

Constants

ENGINE  = 1

Properties

$crop  : array<string, int>
$defQuality  : int
$messages  : array<string, string>
$mode  : string
$modes  : array<string, int>
$newFile  : string|null
$newType  : string
$oldFile  : string|null
$oldType  : string|null
$ratio  : float|null
$resize  : array<string, array<string, int>>
$retype  : array<string, string>
$color  : array<string, int>
$filters  : array<string, mixed>
$forceEdit  : bool
$height  : int
$image  : object
$oldHeight  : int
$oldWidth  : int
$quality  : int
$rotate  : int
$transparent  : bool
$waterMark  : array<string, mixed>
$width  : int

Methods

__construct()  : mixed
convert()  : bool
convertColor()  : array<string, int>
Check and convert colors
create()  : array<string|int, mixed>
Create empty image
getBlob()  : string
Get string representation of image
getFile()  : string
Returns new file name
getHeight()  : int
Returns new height
getOldHeight()  : int
Returns original height
getOldWidth()  : int
Returns original width
getWidth()  : int
Returns new width
load()  : array<string|int, mixed>
Load image and data
loadBlob()  : array<string|int, mixed>
Load image from string
waterMark()  : object
Insert watermark into image
blur()  : object
Blur image
brightness()  : object
Change image brightness
calculate()  : bool
Count new image sizes
calculateWaterMark()  : array<string|int, mixed>
Calculate watermark position and use filters
checkFormat()  : bool
Check if is input image supported
colorize()  : object
Colorize image
contrast()  : object
Change image contrast
copy()  : bool
Copy original file
cutMime()  : string
Return image format
filter()  : object
Apply filters on image
getMessage()  : string
Return readable text of error message
grayscale()  : object
Convert to grayscale
loadExifRotate()  : array<string, int|bool>|null
Get image rotation from EXIF
negative()  : object
Invert colors
pixelate()  : object
Pixelize image
readCrop()  : array<string, int>
replace()  : bool
Replace original image
transform()  : bool
Modify loaded image based on settings
useFilters()  : object
Apply selected filters

Constants

ENGINE

public int ENGINE = 1

Error code

Properties

$crop

public array<string, int> $crop

Crop image borders

$defQuality

public static int $defQuality = 90

Default image quality

$messages

public static array<string, string> $messages = ['FAIL_OPEN' => 'Failed to open file: %s', 'NO_FILE' => 'Missing image file: %s', 'NO_IMAGE' => 'File: %s can not be processed as image', 'NO_MODE' => 'Unsupported scaling mode: %s', 'NO_SUPPORT' => 'Unsupported image format: %s', 'NO_FILTER' => 'Undefined filter type: %s', 'NO_ICC_FILE' => 'Missing ICC profile: %s', 'CORE' => 'Critical error']

Error messages

$mode

public string $mode

Image modification mode from $modes

$modes

public static array<string, int> $modes = ['copy' => 1, 'crop' => 1, 'resize' => 1, 'fill' => 1]

Supported resize modes

$newFile

public string|null $newFile

New image file

$newType

public string $newType

New image type

$oldFile

public string|null $oldFile

Source image

$oldType

public string|null $oldType

Source image type

$ratio

public float|null $ratio

Image ratio

$resize

public array<string, array<string, int>> $resize

Image new resolution

$retype

public static array<string, string> $retype = ['jpeg' => 'jpeg', 'jpg' => 'jpeg', 'png' => 'png', 'gif' => 'gif', 'wbmp' => 'wbmp', 'bmp' => 'bmp', 'webp' => 'webp']

List of supported formats and fix jpg->jpeg

$color

protected array<string, int> $color = ['R' => 0, 'G' => 0, 'B' => 0, 'A' => 0]

Image background color ALPHA IN 0 - 1

$filters

protected array<string, mixed> $filters = []

List of filters and settings

$forceEdit

protected bool $forceEdit = false

Always process

$height

protected int $height

New image height

$image

protected object $image

Image based on used image manipulation class

$oldHeight

protected int $oldHeight

Source image height

$oldWidth

protected int $oldWidth

Source image width

$quality

protected int $quality

Quality of new image

$rotate

protected int $rotate

Image rotation clockwise

$transparent

protected bool $transparent

Is image transparent

$waterMark

protected array<string, mixed> $waterMark = []

Watermark settings

$width

protected int $width

New image width

Methods

__construct()

public __construct(array<string, mixed>|string $mixed) : mixed
Parameters
$mixed : array<string, mixed>|string
Tags
throws
InvalidArgumentException

convert()

public convert(string|null $newFile[, array<string, mixed> $sets = [] ]) : bool
Parameters
$newFile : string|null

null for none

$sets : array<string, mixed> = []
Tags
throws
InvalidArgumentException
Return values
bool

convertColor()

Check and convert colors

public convertColor(array<string, int>|string $para) : array<string, int>
Parameters
$para : array<string, int>|string
Return values
array<string, int>

create()

Create empty image

public abstract create(int $width, int $height, string $type) : array<string|int, mixed>
Parameters
$width : int
$height : int
$type : string
Return values
array<string|int, mixed>

getBlob()

Get string representation of image

public abstract getBlob() : string
Return values
string

getFile()

Returns new file name

public getFile() : string
Return values
string

getHeight()

Returns new height

public getHeight() : int
Return values
int

getOldHeight()

Returns original height

public getOldHeight() : int
Return values
int

getOldWidth()

Returns original width

public getOldWidth() : int
Return values
int

getWidth()

Returns new width

public getWidth() : int
Return values
int

load()

Load image and data

public abstract load(string $file) : array<string|int, mixed>
Parameters
$file : string
Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>

loadBlob()

Load image from string

public abstract loadBlob(string $blob) : array<string|int, mixed>
Parameters
$blob : string
Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>

waterMark()

Insert watermark into image

public abstract waterMark(object $img, array<string, mixed> $wmark) : object
Parameters
$img : object
$wmark : array<string, mixed>
Return values
object

blur()

Blur image

protected abstract blur(object $img, float $val) : object
Parameters
$img : object
$val : float
Return values
object

brightness()

Change image brightness

protected abstract brightness(object $img, float $val) : object
Parameters
$img : object
$val : float
Return values
object

calculate()

Count new image sizes

protected calculate() : bool
Return values
bool

calculateWaterMark()

Calculate watermark position and use filters

protected calculateWaterMark(object $waterMark, int $width, int $height, array<string, mixed> $settings) : array<string|int, mixed>
Parameters
$waterMark : object
$width : int
$height : int
$settings : array<string, mixed>
Return values
array<string|int, mixed>

checkFormat()

Check if is input image supported

protected checkFormat(string $type) : bool
Parameters
$type : string
Return values
bool

colorize()

Colorize image

protected abstract colorize(object $img, array{R?: int, G?: int, B?: int} $colors) : object
Parameters
$img : object
$colors : array{R?: int, G?: int, B?: int}
Return values
object

contrast()

Change image contrast

protected abstract contrast(object $img, float $val) : object
Parameters
$img : object
$val : float
Return values
object

copy()

Copy original file

protected copy() : bool
Return values
bool

cutMime()

Return image format

protected cutMime(string $mime) : string
Parameters
$mime : string
Return values
string

filter()

Apply filters on image

protected filter(object $img, string $type, mixed $arg) : object
Parameters
$img : object
$type : string
$arg : mixed
Tags
throws
InvalidArgumentException
Return values
object

getMessage()

Return readable text of error message

protected getMessage(string $type[, string $para = '' ]) : string
Parameters
$type : string
$para : string = ''
Return values
string

grayscale()

Convert to grayscale

protected abstract grayscale(object $img) : object
Parameters
$img : object
Return values
object

loadExifRotate()

Get image rotation from EXIF

protected loadExifRotate(string $filePath, string $type) : array<string, int|bool>|null
Parameters
$filePath : string
$type : string
Return values
array<string, int|bool>|null

negative()

Invert colors

protected abstract negative(object $img) : object
Parameters
$img : object
Return values
object

pixelate()

Pixelize image

protected abstract pixelate(object $img, float $val) : object
Parameters
$img : object
$val : float
Return values
object

readCrop()

protected readCrop(array<string, int>|int $crop) : array<string, int>
Parameters
$crop : array<string, int>|int
Return values
array<string, int>

replace()

Replace original image

protected replace(object $image) : bool
Parameters
$image : object
Return values
bool

transform()

Modify loaded image based on settings

protected abstract transform(int $newWidth, int $newHeight, int $cutWidth, int $cutHeight) : bool
Parameters
$newWidth : int
$newHeight : int
$cutWidth : int
$cutHeight : int
Return values
bool

useFilters()

Apply selected filters

protected useFilters(object $img, array<string, mixed> $filters) : object
Parameters
$img : object
$filters : array<string, mixed>
Return values
object

        
On this page

Search results