SvgImage

Type
Class
Namespace
Craft
Inherits
Craft\SvgImage » Craft\BaseImage
Since
2.5

Class SvgImage

See also http://craftcms.com

View source

Public Methods

MethodDescription
crop()Crops the image to the specified coordinates.
getExtension()
getHeight()
getSvgString()Get the SVG string.
getWidth()
isTransparent()Returns true if the image is transparent.
loadImage()Loads an image from a file system path.
resize()Re-sizes the image. If $height is not specified, it will default to $width, creating a square.
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.

crop()

Crops the image to the specified coordinates.

View source

Arguments

Returns

Craft\Image

Signature

public Craft\Image crop ( $x1, $x2, $y1, $y2 )

getExtension()

Signature

public string getExtension ( )

getHeight()

Signature

public integer getHeight ( )

getSvgString()

Get the SVG string.

View source

Returns

string

Signature

public string getSvgString ( )

getWidth()

Signature

public integer getWidth ( )

isTransparent()

Returns true if the image is transparent.

View source

Returns

boolean

Signature

public boolean isTransparent ( )

loadImage()

Loads an image from a file system path.

View source

Arguments

Returns

Craft\Image

Throws

Signature

public Craft\Image loadImage ( $path )

resize()

Re-sizes the image. If $height is not specified, it will default to $width, creating a square.

View source

Arguments

Returns

Craft\Image

Signature

public Craft\Image resize ( $targetWidth, $targetHeight = null )

saveAs()

Saves the image to the target path.

View source

Arguments

Returns

null

Throws

Signature

public null saveAs ( $targetPath, $autoQuality = false )

scaleAndCrop()

Scale and crop image to exactly fit the specified size.

View source

Arguments

Returns

Craft\Image

Signature

public Craft\Image scaleAndCrop ( $targetWidth, $targetHeight = null, $scaleIfSmaller = true, $cropPositions = 'center-center' )

scaleToFit()

Scale the image to fit within the specified size.

View source

Arguments

Returns

Craft\Image

Signature

public Craft\Image scaleToFit ( $targetWidth, $targetHeight = null, $scaleIfSmaller = true )

Protected Methods

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

Constants

ConstantDescription
SVG_ASPECT_RE
SVG_CLEANUP_HEIGHT_RE
SVG_CLEANUP_WIDTH_RE
SVG_HEIGHT_RE
SVG_TAG_RE
SVG_VIEWBOX_RE
SVG_WIDTH_RE