PHP Interface Webiny\Component\Image\ImageInterface

Datei anzeigen Open project: Webiny/Framework Interface Usage Examples

Public Methods

Method Description
crop ( integer $width, integer $height, integer $offestX, integer $offestY ) : Webiny\Component\Image\ImageInterface Crop the image to the given dimensions.
getBinary ( array $options = [] ) : string Get image as a binary string.
getFormat ( ) : string Get the image mime-type format.
getInstance ( ) : mixed This method returns the instance of the Image object from the bridged library.
getSize ( ) : 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 ) : Webiny\Component\Image\ImageInterface Resize the image to given dimensions.
rotate ( integer $angle, null | string $bgColor = null ) : Webiny\Component\Image\ImageInterface Rotate the image under the given $angle.
save ( File $file = null, array $options = [] ) Saves the current image to the given location.
setDestination ( File $destination ) Sets the image destination.
setFormat ( string $format ) Sets image mime-type format.
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

crop() public method

Crop the image to the given dimensions.
public crop ( integer $width, integer $height, integer $offestX, integer $offestY ) : Webiny\Component\Image\ImageInterface
$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.
return Webiny\Component\Image\ImageInterface

getBinary() public method

Get image as a binary string.
public getBinary ( array $options = [] ) : string
$options array List of additional options. Possible values are [quality].
return string

getFormat() public method

Can be [jpg, jpeg, png, gif].
public getFormat ( ) : string
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 ( ) : ArrayObject
return 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 ) : Webiny\Component\Image\ImageInterface
$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.
return Webiny\Component\Image\ImageInterface

rotate() public method

Rotate the image under the given $angle.
public rotate ( integer $angle, null | string $bgColor = null ) : Webiny\Component\Image\ImageInterface
$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)
return Webiny\Component\Image\ImageInterface

save() public method

Saves the current image to the given location.
public save ( File $file = null, array $options = [] )
$file Webiny\Component\Storage\File\File
$options array An array of options. Possible keys are [quality, filters].

setDestination() public method

Sets the image destination.
public setDestination ( File $destination )
$destination Webiny\Component\Storage\File\File Destination where to store the image.

setFormat() public method

Sets image mime-type format.
public setFormat ( string $format )
$format string Format name. Supported formats are [jpg, jpeg, png, gif]

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)