PHP Class Webiny\Component\Image\Bridge\Imagine\Image

Inheritance: extends Webiny\Component\Image\Bridge\AbstractImage, use trait Webiny\Component\StdLib\StdLibTrait
Mostra file Open project: Webiny/Framework

Public Methods

Method Description
__construct ( Imagine\Image\ImageInterface $image ) Base constructor.
crop ( integer $width, integer $height, integer $offestX, integer $offestY ) Crop the image to the given dimensions.
getBinary ( array $options = [] ) : string Get image as a binary string.
getInstance ( ) : mixed This method returns the instance of the Image object from the bridged library.
getSize ( ) : Webiny\Component\Image\ArrayObject Returns the width and height of the image in pixels.
paste ( Webiny\Component\Image\ImageInterface $image, integer $offsetX, integer $offsetY ) Paste another image into this one a the specified dimension.
resize ( integer $width, integer $height, boolean $preserveAspectRatio = true ) Resize the image to given dimensions.
rotate ( integer $angle, null | string $bgColor = null ) Rotate the image under the given $angle.
show ( ) : string Output the image into the browser.
thumbnail ( integer $width, integer $height, boolean | string $cropOrPad = false, null | string $padColor = null ) This is a method that combines resize, crop and paste methods in order to generate a thumbnail from the given image.

Method Details

__construct() public method

Base constructor.
public __construct ( Imagine\Image\ImageInterface $image )
$image Imagine\Image\ImageInterface

crop() public method

Crop the image to the given dimensions.
public crop ( integer $width, integer $height, integer $offestX, integer $offestY )
$width integer Width on the new image.
$height integer Height of the new image.
$offestX integer Crop start position on X axis.
$offestY integer Crop start position on Y axis.

getBinary() public method

Get image as a binary string.
public getBinary ( array $options = [] ) : string
$options array An array of options. Possible keys are [quality, filters].
return string

getInstance() public method

The usage of this method is discouraged, but it's necessary for some internal operations.
public getInstance ( ) : mixed
return mixed

getSize() public method

Returns the width and height of the image in pixels.
public getSize ( ) : Webiny\Component\Image\ArrayObject
return Webiny\Component\Image\ArrayObject

paste() public method

Paste another image into this one a the specified dimension.
public paste ( Webiny\Component\Image\ImageInterface $image, integer $offsetX, integer $offsetY )
$image Webiny\Component\Image\ImageInterface Image to paste.
$offsetX integer Offset on x axis.
$offsetY integer Offset on y axis

resize() public method

Resize the image to given dimensions.
public resize ( integer $width, integer $height, boolean $preserveAspectRatio = true )
$width integer Width of the new image.
$height integer Height of the new image.
$preserveAspectRatio boolean Do you wish to preserve the aspect ration while resizing. Default is true. NOTE: If you preserve the aspect ratio, the output image might not match the defined width and height.

rotate() public method

Rotate the image under the given $angle.
public rotate ( integer $angle, null | string $bgColor = null )
$angle integer Angle in degrees how much to rotate the image.
$bgColor null | string Optional parameter that fills the background with the defined color. Following formats are acceptable - "fff" - "ffffff" - array(255,255,255)

show() public method

Output the image into the browser.
public show ( ) : string
return string

thumbnail() public method

The benefit of using this function is that the function can automatically combine crop and resize methods together with the pad feature in order to generate the thumb.
public thumbnail ( integer $width, integer $height, boolean | string $cropOrPad = false, null | string $padColor = null )
$width integer Thumb width.
$height integer Thumb height.
$cropOrPad boolean | string If you set this to 'crop' the method will first resize the image to preserve the aspect ratio and then it will crop the extra pixels to fit the defined width and height. If you set this to 'pad' the method will first do the resize and than it wil create a blank image that has the size of defined width and height and fill it with $padColor, then it will paste the resized image in the center of the new image.
$padColor null | string Parameter that fills the background with the defined color. Following formats are acceptable - "fff" - "ffffff" - array(255,255,255)