ImageMagick
extends Image
in package
using Imagick instead of GD
Table of Contents
Constants
- ENGINE = 3
Properties
- $crop : array<string, int>
- $defQuality : int
- $docRegex : string
- $docType : string
- $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>
- $colorSpace : string
- $filters : array<string, mixed>
- $forceEdit : bool
- $height : int
- $icc : string
- $image : object
- $metadata : array<string|int, string>|bool
- $oldHeight : int
- $oldWidth : int
- $quality : int
- $rotate : int
- $transparent : bool
- $waterMark : array<string, mixed>
- $width : int
- $spaceConvert : array<string, int>
Methods
- __construct() : mixed
- convert() : bool
- Add colorspace support
- 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() : Imagick
- Insert watermark into image
- blur() : Imagick
- Blur image
- brightness() : Imagick
- 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() : Imagick
- Colorize image
- contrast() : Imagick
- 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() : Imagick
- Convert to grayscale
- insertICC() : Imagick
- Set image color profile
- loadExifRotate() : array<string, int|bool>|null
- Get image rotation from EXIF
- negative() : Imagick
- Invert colors
- pixelate() : Imagick
- 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
= 3
Error code
Properties
$crop
public
array<string, int>
$crop
Crop image borders
$defQuality
public
static int
$defQuality
= 90
Default image quality
$docRegex
public
static string
$docRegex
= '/pdf$/i'
Regexp
$docType
public
static string
$docType
= 'jpg'
Image compression for non image files (pdf)
$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' => 'jpg', 'jpg' => 'jpg', 'png' => 'png', 'gif' => 'gif', 'wbmp' => 'wbmp', 'bmp' => 'bmp', 'webp' => 'webp', 'tif' => 'tif']
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
$colorSpace
protected
string
$colorSpace
Set colorspace conversion false (ignore - default) / RGB / CMYK
$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
$icc
protected
string
$icc
Set custom ICC profile - location is relative to this file
$image
protected
object
$image
Image based on used image manipulation class
$metadata
protected
array<string|int, string>|bool
$metadata
Keep selected metadata or false to remove all
$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
$spaceConvert
private
static array<string, int>
$spaceConvert
= ['CMYK' => \Imagick::COLORSPACE_CMYK, 'RGB' => \Imagick::COLORSPACE_SRGB]
List of color spaces
Methods
__construct()
public
__construct(array<string, mixed>|string $mixed) : mixed
Parameters
- $mixed : array<string, mixed>|string
Tags
convert()
Add colorspace support
public
convert(string|null $newFile[, array<string, mixed> $sets = [] ]) : bool
Parameters
- $newFile : string|null
-
null for none
- $sets : array<string, mixed> = []
Tags
Return values
boolconvertColor()
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
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
getBlob() : string
Return values
stringgetFile()
Returns new file name
public
getFile() : string
Return values
stringgetHeight()
Returns new height
public
getHeight() : int
Return values
intgetOldHeight()
Returns original height
public
getOldHeight() : int
Return values
intgetOldWidth()
Returns original width
public
getOldWidth() : int
Return values
intgetWidth()
Returns new width
public
getWidth() : int
Return values
intload()
Load image and data
public
load(string $file) : array<string|int, mixed>
Parameters
- $file : string
Tags
Return values
array<string|int, mixed>loadBlob()
Load image from string
public
loadBlob(string $blob) : array<string|int, mixed>
Parameters
- $blob : string
Tags
Return values
array<string|int, mixed>waterMark()
Insert watermark into image
public
waterMark(Imagick $img, array<string, mixed> $wmark) : Imagick
Parameters
- $img : Imagick
- $wmark : array<string, mixed>
Return values
Imagickblur()
Blur image
protected
blur(Imagick $img, float $val) : Imagick
Parameters
- $img : Imagick
- $val : float
Return values
Imagickbrightness()
Change image brightness
protected
brightness(Imagick $img, float $val) : Imagick
Parameters
- $img : Imagick
- $val : float
Return values
Imagickcalculate()
Count new image sizes
protected
calculate() : bool
Return values
boolcalculateWaterMark()
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
boolcolorize()
Colorize image
protected
colorize(Imagick $img, array{R?: int, G?: int, B?: int} $colors) : Imagick
Parameters
- $img : Imagick
- $colors : array{R?: int, G?: int, B?: int}
Return values
Imagickcontrast()
Change image contrast
protected
contrast(Imagick $img, float $val) : Imagick
Parameters
- $img : Imagick
- $val : float
Return values
Imagickcopy()
Copy original file
protected
copy() : bool
Return values
boolcutMime()
Return image format
protected
cutMime(string $mime) : string
Parameters
- $mime : string
Return values
stringfilter()
Apply filters on image
protected
filter(object $img, string $type, mixed $arg) : object
Parameters
- $img : object
- $type : string
- $arg : mixed
Tags
Return values
objectgetMessage()
Return readable text of error message
protected
getMessage(string $type[, string $para = '' ]) : string
Parameters
- $type : string
- $para : string = ''
Return values
stringgrayscale()
Convert to grayscale
protected
grayscale(Imagick $img) : Imagick
Parameters
- $img : Imagick
Return values
ImagickinsertICC()
Set image color profile
protected
insertICC(Imagick $img, string $file) : Imagick
Parameters
- $img : Imagick
- $file : string
Return values
ImagickloadExifRotate()
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>|nullnegative()
Invert colors
protected
negative(Imagick $img) : Imagick
Parameters
- $img : Imagick
Return values
Imagickpixelate()
Pixelize image
protected
pixelate(Imagick $img, float $val) : Imagick
Parameters
- $img : Imagick
- $val : float
Return values
ImagickreadCrop()
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
booltransform()
Modify loaded image based on settings
protected
transform(int $newWidth, int $newHeight, int $cutWidth, int $cutHeight) : bool
Parameters
- $newWidth : int
- $newHeight : int
- $cutWidth : int
- $cutHeight : int
Return values
booluseFilters()
Apply selected filters
protected
useFilters(object $img, array<string, mixed> $filters) : object
Parameters
- $img : object
- $filters : array<string, mixed>