Class yii\imagine\Image

Inheritanceyii\imagine\Image » yii\imagine\BaseImage
Available since version2.0

Image implements most commonly used image manipulation functions using the Imagine library.

Example of use:

// generate a thumbnail image
Image::thumbnail('@webroot/img/test-image.jpg', 120, 120)
    ->save(Yii::getAlias('@runtime/thumb-test-image.jpg'), ['quality' => 50]);

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$driver array|string The driver to use. yii\imagine\BaseImage
$thumbnailBackgroundAlpha string Background alpha (transparency) to use when creating thumbnails in ImageInterface::THUMBNAIL_INSET mode with both width and height specified. yii\imagine\BaseImage
$thumbnailBackgroundColor string Background color to use when creating thumbnails in ImageInterface::THUMBNAIL_INSET mode with both width and height specified. yii\imagine\BaseImage

Public Methods

Hide inherited methods

MethodDescriptionDefined By
autorotate() Rotates an image automatically based on EXIF information. yii\imagine\BaseImage
crop() Crops an image. yii\imagine\BaseImage
frame() Adds a frame around of the image. Please note that the image size will increase by $margin x 2. yii\imagine\BaseImage
getImagine() Returns the Imagine object that supports various image manipulations. yii\imagine\BaseImage
resize() Resizes an image. yii\imagine\BaseImage
setImagine() yii\imagine\BaseImage
text() Draws a text string on an existing image. yii\imagine\BaseImage
thumbnail() Creates a thumbnail image. yii\imagine\BaseImage
watermark() Adds a watermark to an existing image. yii\imagine\BaseImage

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
createImagine() Creates an Imagine object based on the specified $driver. yii\imagine\BaseImage
ensureImageInterfaceInstance() Takes either file path or ImageInterface. In case of file path, creates an instance of ImageInterface from it. yii\imagine\BaseImage
getBox() Returns box for an image to be created. yii\imagine\BaseImage
getThumbnailBox() Returns box for a thumbnail to be created. If one of the dimensions is set to null, another one is calculated automatically based on width to height ratio of original image box. yii\imagine\BaseImage
isUpscaling() Checks if upscaling is going to happen yii\imagine\BaseImage

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
DRIVER_GD2 'gd2' GD2 driver definition for Imagine implementation using the GD library. yii\imagine\BaseImage
DRIVER_GMAGICK 'gmagick' Gmagick driver definition. yii\imagine\BaseImage
DRIVER_IMAGICK 'imagick' Imagick driver definition. yii\imagine\BaseImage