BaseImage
- Type
- Abstract Class
- Namespace
- Craft
- Inherits
- Craft\BaseImage
- Extended by
- Craft\Image, Craft\SvgImage
- Since
- 2.5
Base Image class
See also http://craftcms.com
View source (opens new window)
# Public Methods
Method | Description |
---|---|
crop() | Crops the image to the specified coordinates. |
getExtension() | |
getHeight() | |
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 (opens new window)
Arguments
$x1
(integer (opens new window))$x2
(integer (opens new window))$y1
(integer (opens new window))$y2
(integer (opens new window))
Returns
Signature
public abstract Craft\BaseImage crop ( $x1, $x2, $y1, $y2 )
# getExtension()
Signature
public abstract string getExtension ( )
# getHeight()
Signature
public abstract integer getHeight ( )
# getWidth()
Signature
public abstract integer getWidth ( )
# isTransparent()
Signature
public abstract boolean isTransparent ( )
# loadImage()
Loads an image from a file system path.
View source (opens new window)
Arguments
$path
(string (opens new window))
Returns
Throws
Signature
public abstract Craft\BaseImage loadImage ( $path )
# resize()
Re-sizes the image. If $height is not specified, it will default to $width, creating a square.
View source (opens new window)
Arguments
$targetWidth
(integer (opens new window))$targetHeight
(integer (opens new window), null (opens new window))
Returns
Signature
public abstract Craft\Image resize ( $targetWidth, $targetHeight = null )
# saveAs()
Saves the image to the target path.
View source (opens new window)
Arguments
$targetPath
(string (opens new window))$autoQuality
Returns
Signature
public abstract null saveAs ( $targetPath, $autoQuality = false )
# scaleAndCrop()
Scale and crop image to exactly fit the specified size.
View source (opens new window)
Arguments
$targetWidth
(integer (opens new window))$targetHeight
(integer (opens new window), null (opens new window))$scaleIfSmaller
(boolean (opens new window))$cropPositions
(string (opens new window))
Returns
Signature
public abstract Craft\BaseImage scaleAndCrop ( $targetWidth, $targetHeight = null, $scaleIfSmaller = true, $cropPositions = 'center-center' )
# scaleToFit()
Scale the image to fit within the specified size.
View source (opens new window)
Arguments
$targetWidth
(integer (opens new window))$targetHeight
(integer (opens new window), null (opens new window))$scaleIfSmaller
(boolean (opens new window))
Returns
Signature
public abstract Craft\BaseImage scaleToFit ( $targetWidth, $targetHeight = null, $scaleIfSmaller = true )
# Protected Methods
Method | Description |
---|---|
normalizeDimensions() | Normalizes the given dimensions. If width or height is set to 'AUTO', we calculate the missing dimension. |
# normalizeDimensions()
Normalizes the given dimensions. If width or height is set to 'AUTO', we calculate the missing dimension.
View source (opens new window)
Arguments
$width
(integer (opens new window), string (opens new window))$height
(integer (opens new window), string (opens new window))
Throws
Signature
protected void normalizeDimensions ( &$width, &$height = null )
← BaseIO BaseMigration →