Raster

Type
Class
Namespace
craft\image
Inherits
craft\image\Raster » craft\base\Image » yii\base\BaseObject (opens new window)
Implements
yii\base\Configurable (opens new window)
Since
3.0.0

Raster class is used for raster image manipulations.

View source (opens new window)

# Public Properties

# extension

Type
string (opens new window)
Default value
null
Access
Read-only

View source (opens new window)

# height

Type
integer (opens new window)
Default value
null
Access
Read-only

View source (opens new window)

# imagineImage

Type
\Imagine\Image\AbstractImage, null (opens new window)
Default value
null
Access
Read-only

View source (opens new window)

# interlace

Type
string (opens new window)
Default value
null
Access
Write-only

View source (opens new window)

# isTransparent

Type
boolean (opens new window)
Default value
null
Access
Read-only

View source (opens new window)

# quality

Type
integer (opens new window)
Default value
null
Access
Write-only

View source (opens new window)

# width

Type
integer (opens new window)
Default value
null
Access
Read-only

View source (opens new window)

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__construct() Constructor.
__get() (opens new window) Returns the value of an object property.
__isset() (opens new window) Checks if a property is set, i.e. defined and not null.
__set() (opens new window) Sets value of an object property.
__unset() (opens new window) Sets an object property to null.
canGetProperty() (opens new window) Returns a value indicating whether a property can be read.
canSetProperty() (opens new window) Returns a value indicating whether a property can be set.
className() (opens new window) Returns the fully qualified name of this class.
crop() Crops the image to the specified coordinates.
disableAnimation() Disable animation if this is an animated image.
flipHorizontally() Flips the image horizontally.
flipVertically() Flips the image vertically.
getExifMetadata() Returns EXIF metadata for a file by its path.
getExtension() Returns the file extension.
getHeight() Returns the height of the image.
getImagineImage() Return the Imagine Image instance
getIsTransparent() Returns whether the image is transparent.
getTextBox() Returns the bounding text box for a text string and an angle
getWidth() Returns the width of the image.
hasMethod() (opens new window) Returns a value indicating whether a method is defined.
hasProperty() (opens new window) Returns a value indicating whether a property is defined.
init() (opens new window) Initializes the object.
loadFromSVG() Loads an image from an SVG string.
loadImage() Loads an image from a file system path.
resize() Resizes the image.
rotate() Rotates the image by the given degrees.
saveAs() Saves the image to the target path.
scaleAndCrop() Scale and crop image to exactly fit the specified size.
scaleToFit() Scale the image to fit within the specified size.
setFontProperties() Sets properties for text drawing on the image.
setInterlace() Sets the interlace setting.
setQuality() Sets the image quality.
writeText() Writes text on an image.

# __construct()

Constructor.

The default implementation does two things:

If this method is overridden in a child class, it is recommended that

  • the last parameter of the constructor is a configuration array, like $config here.
  • call the parent implementation at the end of the constructor.

View source (opens new window)

Arguments

# crop()

Crops the image to the specified coordinates.

View source (opens new window)

Arguments

Returns

static – Self reference

# disableAnimation()

Disable animation if this is an animated image.

View source (opens new window)

Returns

$this

# flipHorizontally()

Flips the image horizontally.

View source (opens new window)

Returns

static – Self reference

# flipVertically()

Flips the image vertically.

View source (opens new window)

Returns

static – Self reference

# getExifMetadata()

Returns EXIF metadata for a file by its path.

View source (opens new window)

Arguments

Returns

array (opens new window)

# getExtension()

Returns the file extension.

View source (opens new window)

Returns

string (opens new window)

# getHeight()

Returns the height of the image.

View source (opens new window)

Returns

integer (opens new window)

# getImagineImage()

Return the Imagine Image instance

View source (opens new window)

Returns

\Imagine\Image\AbstractImage, null (opens new window)

# getIsTransparent()

Returns whether the image is transparent.

View source (opens new window)

Returns

boolean (opens new window)

# getTextBox()

Returns the bounding text box for a text string and an angle

View source (opens new window)

Arguments

Returns

\Imagine\Image\BoxInterface

Throws

# getWidth()

Returns the width of the image.

View source (opens new window)

Returns

integer (opens new window)

# loadFromSVG()

Loads an image from an SVG string.

View source (opens new window)

Arguments

Returns

static – Self reference

Throws

# loadImage()

Loads an image from a file system path.

View source (opens new window)

Arguments

Returns

static, craft\image\Svg – Self reference

Throws

# resize()

Resizes the image.

View source (opens new window)

Arguments

Returns

static – Self reference

# rotate()

Rotates the image by the given degrees.

View source (opens new window)

Arguments

Returns

static – Self reference

# saveAs()

Saves the image to the target path.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Throws

# scaleAndCrop()

Scale and crop image to exactly fit the specified size.

View source (opens new window)

Arguments

Returns

static – Self reference

# scaleToFit()

Scale the image to fit within the specified size.

View source (opens new window)

Arguments

Returns

static – Self reference

# setFontProperties()

Sets properties for text drawing on the image.

View source (opens new window)

Arguments

# setInterlace()

Sets the interlace setting.

View source (opens new window)

Arguments

Returns

static – Self reference

# setQuality()

Sets the image quality.

View source (opens new window)

Arguments

Returns

static – Self reference

# writeText()

Writes text on an image.

View source (opens new window)

Arguments

Throws

# Protected Methods

Method Description
normalizeDimensions() Normalizes the given dimensions. If width or height is set to 'AUTO', we calculate the missing dimension.