Class craft\image\Svg
- Inheritance
- craft\image\Svg » craft\base\Image » yii\base\BaseObject
- Implements
- yii\base\Configurable
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/image/Svg.php
Svg class is used for SVG file manipulations.
Method | Description | Defined By |
---|---|---|
__call() |
Calls the named method which is not a class method. | yii\base\BaseObject |
__construct() |
Constructor. | yii\base\BaseObject |
__get() |
Returns the value of an object property. | yii\base\BaseObject |
__isset() |
Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() |
Sets value of an object property. | yii\base\BaseObject |
__unset() |
Sets an object property to null. | yii\base\BaseObject |
canGetProperty() |
Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() |
Returns a value indicating whether a property can be set. | yii\base\BaseObject |
className() |
Returns the fully qualified name of this class. | yii\base\BaseObject |
crop() |
Crops the image to the specified coordinates. | craft\image\Svg |
getExtension() |
Returns the file extension. | craft\image\Svg |
getHeight() |
Returns the height of the image. | craft\image\Svg |
getIsTransparent() |
Returns whether the image is transparent. | craft\image\Svg |
getSvgString() |
Returns the SVG string. | craft\image\Svg |
getWidth() |
Returns the width of the image. | craft\image\Svg |
hasMethod() |
Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasProperty() |
Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() |
Initializes the object. | yii\base\BaseObject |
loadImage() |
Loads an image from a file system path. | craft\image\Svg |
resize() |
Resizes the image. | craft\image\Svg |
saveAs() |
Saves the image to the target path. | craft\image\Svg |
scaleAndCrop() |
Scale and crop image to exactly fit the specified size. | craft\image\Svg |
scaleToFit() |
Scale the image to fit within the specified size. | craft\image\Svg |
Method | Description | Defined By |
---|---|---|
normalizeDimensions() |
Normalizes the given dimensions. If width or height is set to 'AUTO', we calculate the missing dimension. | craft\base\Image |
Constant | Value | Description | Defined By |
---|---|---|---|
SVG_ASPECT_RE |
'/( | craft\image\Svg | |
SVG_CLEANUP_HEIGHT_RE |
'/( | craft\image\Svg | |
SVG_CLEANUP_WIDTH_RE |
'/( | craft\image\Svg | |
SVG_HEIGHT_RE |
'/( | craft\image\Svg | |
SVG_TAG_RE |
'/ | ||
SVG_VIEWBOX_RE |
'/( | craft\image\Svg | |
SVG_WIDTH_RE |
'/( | craft\image\Svg |
Method Details
crop()
public method
#
Crops the image to the specified coordinates.
public static crop ( \craft\image\int $x1, \craft\image\int $x2, \craft\image\int $y1, \craft\image\int $y2 )
$x1 |
integer | |
$x2 |
integer | |
$y1 |
integer | |
$y2 |
integer | |
return | static | Self reference |
---|
getExtension()
public method
#
Returns the file extension.
public string getExtension ( )
getHeight()
public method
#
Returns the height of the image.
public integer getHeight ( )
getIsTransparent()
public method
#
Returns whether the image is transparent.
public boolean getIsTransparent ( )
getSvgString()
public method
#
Returns the SVG string.
public string getSvgString ( )
getWidth()
public method
#
Returns the width of the image.
public integer getWidth ( )
loadImage()
public method
#
Loads an image from a file system path.
public static, craft\image\Svg loadImage ( \craft\image\string $path )
$path |
string | |
return | static, craft\image\Svg | Self reference |
---|---|---|
throws | craft\errors\ImageException | if the file cannot be loaded |
resize()
public method
#
Resizes the image.
public static resize ( \craft\image\int $targetWidth, \craft\image\int $targetHeight = null )
$targetWidth |
integer | The target width |
$targetHeight |
integer, null | The target height. Defaults to $targetWidth if omitted, creating a square. |
return | static | Self reference |
---|
saveAs()
public method
#
Saves the image to the target path.
public boolean saveAs ( \craft\image\string $targetPath, \craft\image\bool $autoQuality = false )
$targetPath |
string | |
$autoQuality |
boolean | |
throws | craft\errors\ImageException | if the image cannot be saved. |
---|
scaleAndCrop()
public method
#
Scale and crop image to exactly fit the specified size.
public static scaleAndCrop ( \craft\image\int $targetWidth = null, \craft\image\int $targetHeight = null, \craft\image\bool $scaleIfSmaller = true, $cropPosition = 'center-center' )
$targetWidth |
integer, null | |
$targetHeight |
integer, null | |
$scaleIfSmaller |
boolean | |
$cropPosition |
mixed | |
return | static | Self reference |
---|
scaleToFit()
public method
#
Scale the image to fit within the specified size.
public static scaleToFit ( \craft\image\int $targetWidth, \craft\image\int $targetHeight = null, \craft\image\bool $scaleIfSmaller = true )
$targetWidth |
integer | |
$targetHeight |
integer, null | |
$scaleIfSmaller |
boolean | |
return | static | Self reference |
---|