PHP Class Image_GD, yii-easyimage

Author: Kohana Team
Inheritance: extends Image
Show file Open project: zhdanovartur/yii-easyimage Class Usage Examples

Protected Properties

Property Type Description
$_create_function Function name to open Image
$_image Temporary image resource
$_isProgressiveJpeg

Public Methods

Method Description
__construct ( string $file, boolean $useProgressiveJpeg = false ) : void Runs [Image_GD::check] and loads the image.
__destruct ( ) : void Destroys the loaded image to free up resources.
check ( ) : boolean Checks if GD is enabled and bundled. Bundled GD is required for some methods to work. Exceptions will be thrown from those methods when GD is not bundled.

Protected Methods

Method Description
_create ( integer $width, integer $height ) : resource Create an empty image with the given width and height.
_do_background ( integer $r, integer $g, integer $b, integer $opacity ) : void Execute a background.
_do_crop ( integer $width, integer $height, integer $offset_x, integer $offset_y ) : void Execute a crop.
_do_flip ( integer $direction ) : void Execute a flip.
_do_reflection ( integer $height, integer $opacity, boolean $fade_in ) : void Execute a reflection.
_do_render ( string $type, integer $quality ) : string Execute a render.
_do_resize ( integer $width, integer $height ) : void Execute a resize.
_do_rotate ( integer $degrees ) : void Execute a rotation.
_do_save ( string $file, integer $quality ) : boolean Execute a save.
_do_sharpen ( integer $amount ) : void Execute a sharpen.
_do_watermark ( $watermark, integer $offset_x, integer $offset_y, integer $opacity ) : void Execute a watermarking.
_load_image ( ) : void Loads an image into GD.
_save_function ( string $extension, integer &$quality ) : array Get the GD saving function and image type for this extension.
_set_interlacing ( resource $image ) Sets an interlace mode.

Method Details

__construct() public method

Runs [Image_GD::check] and loads the image.
public __construct ( string $file, boolean $useProgressiveJpeg = false ) : void
$file string image file path
$useProgressiveJpeg boolean use progressive JPEG format
return void

__destruct() public method

Destroys the loaded image to free up resources.
public __destruct ( ) : void
return void

_create() protected method

Create an empty image with the given width and height.
protected _create ( integer $width, integer $height ) : resource
$width integer image width
$height integer image height
return resource

_do_background() protected method

Execute a background.
protected _do_background ( integer $r, integer $g, integer $b, integer $opacity ) : void
$r integer red
$g integer green
$b integer blue
$opacity integer opacity
return void

_do_crop() protected method

Execute a crop.
protected _do_crop ( integer $width, integer $height, integer $offset_x, integer $offset_y ) : void
$width integer new width
$height integer new height
$offset_x integer offset from the left
$offset_y integer offset from the top
return void

_do_flip() protected method

Execute a flip.
protected _do_flip ( integer $direction ) : void
$direction integer direction to flip
return void

_do_reflection() protected method

Execute a reflection.
protected _do_reflection ( integer $height, integer $opacity, boolean $fade_in ) : void
$height integer reflection height
$opacity integer reflection opacity
$fade_in boolean TRUE to fade out, FALSE to fade in
return void

_do_render() protected method

Execute a render.
protected _do_render ( string $type, integer $quality ) : string
$type string image type: png, jpg, gif, etc
$quality integer quality
return string

_do_resize() protected method

Execute a resize.
protected _do_resize ( integer $width, integer $height ) : void
$width integer new width
$height integer new height
return void

_do_rotate() protected method

Execute a rotation.
protected _do_rotate ( integer $degrees ) : void
$degrees integer degrees to rotate
return void

_do_save() protected method

Execute a save.
protected _do_save ( string $file, integer $quality ) : boolean
$file string new image filename
$quality integer quality
return boolean

_do_sharpen() protected method

Execute a sharpen.
protected _do_sharpen ( integer $amount ) : void
$amount integer amount to sharpen
return void

_do_watermark() protected method

Execute a watermarking.
protected _do_watermark ( $watermark, integer $offset_x, integer $offset_y, integer $opacity ) : void
$offset_x integer offset from the left
$offset_y integer offset from the top
$opacity integer opacity of watermark
return void

_load_image() protected method

Loads an image into GD.
protected _load_image ( ) : void
return void

_save_function() protected method

Also normalizes the quality setting
protected _save_function ( string $extension, integer &$quality ) : array
$extension string image type: png, jpg, etc
$quality integer image quality
return array save function, IMAGETYPE_* constant

_set_interlacing() protected method

Sets an interlace mode.
protected _set_interlacing ( resource $image )
$image resource Image to apply interlacing. This is useful for creating progressive jpeg images.

check() public static method

Checks if GD is enabled and bundled. Bundled GD is required for some methods to work. Exceptions will be thrown from those methods when GD is not bundled.
public static check ( ) : boolean
return boolean

Property Details

$_create_function protected property

Function name to open Image
protected $_create_function

$_image protected property

Temporary image resource
protected $_image

$_isProgressiveJpeg protected property

protected $_isProgressiveJpeg