Class yii\imagine\BaseImage
Inheritance | yii\imagine\BaseImage |
---|---|
Subclasses | yii\imagine\Image |
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2-imagine/blob/master/BaseImage.php |
BaseImage provides concrete implementation for yii\imagine\Image.
Do not use BaseImage. Use yii\imagine\Image instead.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$driver | array|string | The driver to use. | yii\imagine\BaseImage |
Public Methods
Method | Description | Defined By |
---|---|---|
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 |
setImagine() | yii\imagine\BaseImage | |
text() | Draws a text string on an existing image. | yii\imagine\BaseImage |
thumbnail() | Creates a thumbnail image. The function differs from \Imagine\Image\ImageInterface::thumbnail() function that
it keeps the aspect ratio of the image. |
yii\imagine\BaseImage |
watermark() | Adds a watermark to an existing image. | yii\imagine\BaseImage |
Protected Methods
Method | Description | Defined By |
---|---|---|
createImagine() | Creates an Imagine object based on the specified $driver. |
yii\imagine\BaseImage |
Constants
Constant | Value | Description | Defined 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 |
Property Details
The driver to use. This can be either a single driver name or an array of driver names. If the latter, the first available driver will be used.
Method Details
Creates an Imagine
object based on the specified $driver.
\Imagine\Image\ImagineInterface createImagine( ) | ||
return | \Imagine\Image\ImagineInterface | The new |
---|---|---|
throws | yii\base\InvalidConfigException | if $driver is unknown or the system doesn't support any $driver. |
Crops an image.
For example,
$obj->crop('path\to\image.jpg', 200, 200, [5, 5]);
$point = new \Imagine\Image\Point(5, 5);
$obj->crop('path\to\image.jpg', 200, 200, $point);
\Imagine\Image\ImageInterface crop( $filename, $width, $height, array $start = [0, 0] ) | ||
$filename | string | The image file path or path alias. |
$width | integer | The crop width |
$height | integer | The crop height |
$start | array | The starting point. This must be an array with two elements representing |
throws | yii\base\InvalidParamException | if the |
---|
Adds a frame around of the image. Please note that the image size will increase by $margin
x 2.
\Imagine\Image\ImageInterface frame( $filename, $margin = 20, $color = '666', $alpha = 100 ) | ||
$filename | string | The full path to the image file |
$margin | integer | The frame size to add around the image |
$color | string | The frame color |
$alpha | integer | The alpha value of the frame. |
Returns the Imagine
object that supports various image manipulations.
\Imagine\Image\ImagineInterface getImagine( ) | ||
return | \Imagine\Image\ImagineInterface | The |
---|
void setImagine( $imagine ) | ||
$imagine | \Imagine\Image\ImagineInterface | The |
Draws a text string on an existing image.
\Imagine\Image\ImageInterface text( $filename, $text, $fontFile, array $start = [0, 0], array $fontOptions = [] ) | ||
$filename | string | The image file path or path alias. |
$text | string | The text to write to the image |
$fontFile | string | The file path or path alias |
$start | array | The starting position of the text. This must be an array with two elements representing |
$fontOptions | array | The font options. The following options may be specified:
|
throws | yii\base\InvalidParamException | if |
---|
Creates a thumbnail image. The function differs from \Imagine\Image\ImageInterface::thumbnail()
function that
it keeps the aspect ratio of the image.
\Imagine\Image\ImageInterface thumbnail( $filename, $width, $height, $mode = \Imagine\Image\ManipulatorInterface::THUMBNAIL_OUTBOUND ) | ||
$filename | string | The image file path or path alias. |
$width | integer | The width in pixels to create the thumbnail |
$height | integer | The height in pixels to create the thumbnail |
$mode | string |
Adds a watermark to an existing image.
\Imagine\Image\ImageInterface watermark( $filename, $watermarkFilename, array $start = [0, 0] ) | ||
$filename | string | The image file path or path alias. |
$watermarkFilename | string | The file path or path alias of the watermark image. |
$start | array | The starting point. This must be an array with two elements representing |
throws | yii\base\InvalidParamException | if |
---|