PHP Class WP_Image_Editor_Imagick, wordpress

Since: 3.5.0
Inheritance: extends WP_Image_Editor
Show file Open project: johnpbloch/wordpress Class Usage Examples

Protected Properties

Property Type Description
$image Imagick Imagick object.

Public Methods

Method Description
__destruct ( )
crop ( integer $src_x, integer $src_y, integer $src_w, integer $src_h, integer $dst_w = null, integer $dst_h = null, boolean $src_abs = false ) : boolean | WP_Error Crops Image.
flip ( boolean $horz, boolean $vert ) : true | WP_Error Flips current image.
load ( ) : true | WP_Error Loads image from $this->file into new Imagick Object.
multi_resize ( array $sizes ) : array Resize multiple images from a single source.
resize ( integer | null $max_w, integer | null $max_h, boolean $crop = false ) : boolean | WP_Error Resizes current image.
rotate ( float $angle ) : true | WP_Error Rotates current image counter-clockwise by $angle.
save ( string $destfilename = null, string $mime_type = null ) : array | WP_Error Saves current image to file.
set_quality ( integer $quality = null ) : true | WP_Error Sets Image Compression quality on a 1-100% scale.
stream ( string $mime_type = null ) : true | WP_Error Streams current image to browser.
supports_mime_type ( string $mime_type ) : boolean Checks to see if editor supports the mime-type specified.
test ( array $args = [] ) : boolean Checks to see if current environment supports Imagick.

Protected Methods

Method Description
_save ( Imagick $image, string $filename = null, string $mime_type = null ) : array | WP_Error
pdf_setup ( ) : string | WP_Error Sets up Imagick for PDF processing.
strip_meta ( ) : true | WP_Error Strips all image meta except color profiles from an image.
thumbnail_image ( integer $dst_w, integer $dst_h, string $filter_name = 'FILTER_TRIANGLE', boolean $strip_meta = true ) : boolean | WP_Error Efficiently resize the current image
update_size ( integer $width = null, integer $height = null ) : true | WP_Error Sets or updates current image size.

Method Details

__destruct() public method

public __destruct ( )

_save() protected method

protected _save ( Imagick $image, string $filename = null, string $mime_type = null ) : array | WP_Error
$image Imagick
$filename string
$mime_type string
return array | WP_Error

crop() public method

Crops Image.
Since: 3.5.0
public crop ( integer $src_x, integer $src_y, integer $src_w, integer $src_h, integer $dst_w = null, integer $dst_h = null, boolean $src_abs = false ) : boolean | WP_Error
$src_x integer The start x position to crop from.
$src_y integer The start y position to crop from.
$src_w integer The width to crop.
$src_h integer The height to crop.
$dst_w integer Optional. The destination width.
$dst_h integer Optional. The destination height.
$src_abs boolean Optional. If the source crop points are absolute.
return boolean | WP_Error

flip() public method

Flips current image.
Since: 3.5.0
public flip ( boolean $horz, boolean $vert ) : true | WP_Error
$horz boolean Flip along Horizontal Axis
$vert boolean Flip along Vertical Axis
return true | WP_Error

load() public method

Loads image from $this->file into new Imagick Object.
Since: 3.5.0
public load ( ) : true | WP_Error
return true | WP_Error True if loaded; WP_Error on failure.

multi_resize() public method

Resize multiple images from a single source.
Since: 3.5.0
public multi_resize ( array $sizes ) : array
$sizes array { An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'. Either a height or width must be provided. If one of the two is set to null, the resize will maintain aspect ratio according to the provided dimension. @type array $size { Array of height, width values, and whether to crop. @type int $width Image width. Optional if `$height` is specified. @type int $height Image height. Optional if `$width` is specified. @type bool $crop Optional. Whether to crop the image. Default false. } }
return array An array of resized images' metadata by size.

pdf_setup() protected method

Increases rendering DPI and only loads first page.
Since: 4.7.0
protected pdf_setup ( ) : string | WP_Error
return string | WP_Error File to load or WP_Error on failure.

resize() public method

At minimum, either a height or width must be provided. If one of the two is set to null, the resize will maintain aspect ratio according to the provided dimension.
Since: 3.5.0
public resize ( integer | null $max_w, integer | null $max_h, boolean $crop = false ) : boolean | WP_Error
$max_w integer | null Image width.
$max_h integer | null Image height.
$crop boolean
return boolean | WP_Error

rotate() public method

Rotates current image counter-clockwise by $angle.
Since: 3.5.0
public rotate ( float $angle ) : true | WP_Error
$angle float
return true | WP_Error

save() public method

Saves current image to file.
Since: 3.5.0
public save ( string $destfilename = null, string $mime_type = null ) : array | WP_Error
$destfilename string
$mime_type string
return array | WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}

set_quality() public method

Sets Image Compression quality on a 1-100% scale.
Since: 3.5.0
public set_quality ( integer $quality = null ) : true | WP_Error
$quality integer Compression Quality. Range: [1,100]
return true | WP_Error True if set successfully; WP_Error on failure.

stream() public method

Streams current image to browser.
Since: 3.5.0
public stream ( string $mime_type = null ) : true | WP_Error
$mime_type string
return true | WP_Error

strip_meta() protected method

Strips all image meta except color profiles from an image.
Since: 4.5.0
protected strip_meta ( ) : true | WP_Error
return true | WP_Error True if stripping metadata was successful. WP_Error object on error.

supports_mime_type() public static method

Checks to see if editor supports the mime-type specified.
Since: 3.5.0
public static supports_mime_type ( string $mime_type ) : boolean
$mime_type string
return boolean

test() public static method

We require Imagick 2.2.0 or greater, based on whether the queryFormats() method can be called statically.
Since: 3.5.0
public static test ( array $args = [] ) : boolean
$args array
return boolean

thumbnail_image() protected method

This is a WordPress specific implementation of Imagick::thumbnailImage(), which resizes an image to given dimensions and removes any associated profiles.
Since: 4.5.0
protected thumbnail_image ( integer $dst_w, integer $dst_h, string $filter_name = 'FILTER_TRIANGLE', boolean $strip_meta = true ) : boolean | WP_Error
$dst_w integer The destination width.
$dst_h integer The destination height.
$filter_name string Optional. The Imagick filter to use when resizing. Default 'FILTER_TRIANGLE'.
$strip_meta boolean Optional. Strip all profiles, excluding color profiles, from the image. Default true.
return boolean | WP_Error

update_size() protected method

Sets or updates current image size.
Since: 3.5.0
protected update_size ( integer $width = null, integer $height = null ) : true | WP_Error
$width integer
$height integer
return true | WP_Error

Property Details

$image protected property

Imagick object.
protected Imagick $image
return Imagick