Image_Backend
interface Image_Backend (View source)
Image_Backend
A backend for manipulation of images via the Image class
Constants
ORIENTATION_SQUARE |
Represents a square orientation |
ORIENTATION_PORTRAIT |
Represents a portrait orientation |
ORIENTATION_LANDSCAPE |
Represents a landscape orientation |
Methods
Create a new backend with the given object
Write to the given asset store
Resize the image by preserving aspect ratio. By default, the image cannot be resized to be larger than its current size.
Resize an image by width. Preserves aspect ratio.
Resize an image by height. Preserves aspect ratio.
Return a clone of this image resized, with space filled in with the given colour.
Resize an image to cover the given width/height completely, and crop off any overhanging edges.
Crop's part of image.
Set whether this image backend is allowed to output animated images as a result of manipulations.
Get whether this image backend is allowed to output animated images as a result of manipulations.
Discards all animation frames of the current image instance except the one at the given position. Turns an animated image into a static one.
Details
__construct(AssetContainer|null $assetContainer = null)
Create a new backend with the given object
int
getWidth()
Get the width of the image
int
getHeight()
Get the height of the image
Image_Backend
loadFromContainer(AssetContainer $assetContainer)
Populate the backend with a given object
Image_Backend
loadFrom(string $path)
Populate the backend from a local path
mixed
getImageResource()
Get the currently assigned image resource
Image_Backend
setImageResource($resource)
Set the currently assigned image resource
array
writeToStore(AssetStore $assetStore, string $filename, string|null $hash = null, string|null $variant = null, array $config = [])
Write to the given asset store
bool
writeTo(string $path)
Write the backend to a local path
Image_Backend
setQuality(int $quality)
Set the quality to a value between 0 and 100
int
getQuality()
Get the current quality (between 0 and 100).
Image_Backend|null
resize(int $width, int $height)
Resize an image, skewing it as necessary.
Image_Backend|null
resizeRatio(int $width, int $height, bool $useAsMinimum = false)
Resize the image by preserving aspect ratio. By default, the image cannot be resized to be larger than its current size.
Passing true to useAsMinimum will allow the image to be scaled up.
Image_Backend|null
resizeByWidth(int $width)
Resize an image by width. Preserves aspect ratio.
Image_Backend|null
resizeByHeight(int $height)
Resize an image by height. Preserves aspect ratio.
Image_Backend|null
paddedResize(string $width, string $height, string $backgroundColour = 'FFFFFF', int $transparencyPercent = 0)
Return a clone of this image resized, with space filled in with the given colour.
Image_Backend|null
croppedResize(int $width, int $height, string $position = 'center')
Resize an image to cover the given width/height completely, and crop off any overhanging edges.
Image_Backend|null
crop(int $top, int $left, int $width, int $height, string $position, string $backgroundColour = 'FFFFFF')
Crop's part of image.
Image_Backend
setAllowsAnimationInManipulations(bool $allow)
Set whether this image backend is allowed to output animated images as a result of manipulations.
bool
getAllowsAnimationInManipulations()
Get whether this image backend is allowed to output animated images as a result of manipulations.
bool
getIsAnimated()
Check if the image is animated (e.g. an animated GIF).
Will return false if animations are not allowed for manipulations.
Image_Backend|null
removeAnimation(int|string $position)
Discards all animation frames of the current image instance except the one at the given position. Turns an animated image into a static one.