class InterventionBackend implements Image_Backend, Flushable

Traits

Provides extensions to this object to integrate it with standard config API methods.

Constants

CACHE_MARK

Cache prefix for marking

CACHE_DIMENSIONS

Cache prefix for dimensions

FAILED_INVALID

This file is invalid because it is not image data, or it cannot be processed by the given backend

FAILED_MISSING

This file is invalid as it is missing from the filesystem

FAILED_UNKNOWN

Some unknown error

Config options

error_cache_ttl array How long to cache each error type
local_temp_path string Configure where cached intervention files will be stored

Methods

static Config_ForClass
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .

mixed
stat(string $name) deprecated

Get inherited config value

mixed
uninherited(string $name)

Gets the uninherited value for the given config option

$this
set_stat(string $name, mixed $value) deprecated

Update the config value for a given property

__construct(AssetContainer $assetContainer = null)

Create a new backend with the given object

string
getTempPath()

No description

$this
setTempPath(string $path)

No description

CacheInterface
getCache()

No description

$this
setCache(CacheInterface $cache)

No description

$this
setAssetContainer(AssetContainer $assetContainer)

No description

ImageManager
getImageManager()

No description

$this
setImageManager(ImageManager $manager)

No description

loadFromContainer(AssetContainer $assetContainer)

Populate the backend with a given object

mixed
getImageResource()

Get the currently assigned image resource, or generates one if not yet assigned.

loadFrom(string $path)

Populate the backend from a local path

setImageResource(Image $image)

No description

array
writeToStore(AssetStore $assetStore, string $filename, string $hash = null, string $variant = null, array $config = array())

Write to the given asset store

bool
writeTo(string $path)

Write the backend to a local path

int
getQuality()

No description

int
getWidth()

No description

int
getHeight()

No description

setQuality(int $quality)

Set the quality to a value between 0 and 100

resize(int $width, int $height)

Resize an image, skewing it as necessary.

resizeRatio(int $width, int $height, bool $useAsMinimum = false)

Resize the image by preserving aspect ratio. By default, it will keep the image inside the maxWidth and maxHeight. Passing useAsMinimum will make the smaller dimension equal to the maximum corresponding dimension

resizeByWidth(int $width)

Resize an image by width. Preserves aspect ratio.

resizeByHeight(int $height)

Resize an image by height. Preserves aspect ratio.

paddedResize(int $width, int $height, string $backgroundColor = "FFFFFF", int $transparencyPercent)

Return a clone of this image resized, with space filled in with the given colour

croppedResize(int $width, int $height)

Resize an image to cover the given width/height completely, and crop off any overhanging edges.

crop(int $top, int $left, int $width, int $height)

Crop's part of image.

__destruct()

Make sure we clean up the image resource when this object is destroyed

static 
flush()

This function is triggered early in the request if the "flush" query parameter has been set. Each class that implements Flushable implements this function which looks after it's own specific flushing functionality.

Details

in Configurable at line 20
static Config_ForClass config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .

....).

Return Value

Config_ForClass

in Configurable at line 32
mixed stat(string $name) deprecated

deprecated 5.0 Use ->config()->get() instead

Get inherited config value

Parameters

string $name

Return Value

mixed

in Configurable at line 44
mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

in Configurable at line 57
$this set_stat(string $name, mixed $value) deprecated

deprecated 5.0 Use ->config()->set() instead

Update the config value for a given property

Parameters

string $name
mixed $value

Return Value

$this

at line 105
__construct(AssetContainer $assetContainer = null)

Create a new backend with the given object

Parameters

AssetContainer $assetContainer Object to load from

at line 113
string getTempPath()

Return Value

string The temporary local path for this image

at line 123
$this setTempPath(string $path)

Parameters

string $path

Return Value

$this

at line 132
CacheInterface getCache()

Return Value

CacheInterface

at line 145
$this setCache(CacheInterface $cache)

Parameters

CacheInterface $cache

Return Value

$this

at line 154
AssetContainer getAssetContainer()

Return Value

AssetContainer

at line 164
$this setAssetContainer(AssetContainer $assetContainer)

Parameters

AssetContainer $assetContainer

Return Value

$this

at line 174
ImageManager getImageManager()

Return Value

ImageManager

at line 187
$this setImageManager(ImageManager $manager)

Parameters

ImageManager $manager

Return Value

$this

at line 199
loadFromContainer(AssetContainer $assetContainer)

Populate the backend with a given object

Parameters

AssetContainer $assetContainer Object to load from

at line 210
mixed getImageResource()

Get the currently assigned image resource, or generates one if not yet assigned.

Note: This method may return null if error

Return Value

mixed

at line 297
loadFrom(string $path)

Populate the backend from a local path

Parameters

string $path

at line 328
setImageResource(Image $image)

Parameters

Image $image

at line 346
array writeToStore(AssetStore $assetStore, string $filename, string $hash = null, string $variant = null, array $config = array())

Write to the given asset store

Parameters

AssetStore $assetStore
string $filename Name for the resulting file
string $hash Hash of original file, if storing a variant.
string $variant Name of variant, if storing a variant.
array $config Write options. {see AssetStore}

Return Value

array Tuple associative array (Filename, Hash, Variant) Unless storing a variant, the hash will be calculated from the given data.

Exceptions

BadMethodCallException If image isn't valid

at line 382
bool writeTo(string $path)

Write the backend to a local path

Parameters

string $path

Return Value

bool if the write was successful

Exceptions

BadMethodCallException If image isn't valid

at line 399
int getQuality()

Return Value

int

at line 509
int getWidth()

Return Value

int The width of the image

at line 518
int getHeight()

Return Value

int The height of the image

at line 530
setQuality(int $quality)

Set the quality to a value between 0 and 100

Parameters

int $quality

at line 543
Image_Backend resize(int $width, int $height)

Resize an image, skewing it as necessary.

Parameters

int $width
int $height

Return Value

Image_Backend

at line 562
Image_Backend resizeRatio(int $width, int $height, bool $useAsMinimum = false)

Resize the image by preserving aspect ratio. By default, it will keep the image inside the maxWidth and maxHeight. Passing useAsMinimum will make the smaller dimension equal to the maximum corresponding dimension

Parameters

int $width
int $height
bool $useAsMinimum If true, image will be sized outside of these dimensions. If false (default) image will be sized inside these dimensions.

Return Value

Image_Backend

at line 586
Image_Backend resizeByWidth(int $width)

Resize an image by width. Preserves aspect ratio.

Parameters

int $width

Return Value

Image_Backend

at line 601
Image_Backend resizeByHeight(int $height)

Resize an image by height. Preserves aspect ratio.

Parameters

int $height

Return Value

Image_Backend

at line 619
Image_Backend paddedResize(int $width, int $height, string $backgroundColor = "FFFFFF", int $transparencyPercent)

Return a clone of this image resized, with space filled in with the given colour

Parameters

int $width
int $height
string $backgroundColor
int $transparencyPercent

Return Value

Image_Backend

at line 660
Image_Backend croppedResize(int $width, int $height)

Resize an image to cover the given width/height completely, and crop off any overhanging edges.

Parameters

int $width
int $height

Return Value

Image_Backend

at line 677
Image_Backend crop(int $top, int $left, int $width, int $height)

Crop's part of image.

Parameters

int $top y position of left upper corner of crop rectangle
int $left x position of left upper corner of crop rectangle
int $width rectangle width
int $height rectangle height

Return Value

Image_Backend

at line 794
__destruct()

Make sure we clean up the image resource when this object is destroyed

at line 813
static flush()

This function is triggered early in the request if the "flush" query parameter has been set. Each class that implements Flushable implements this function which looks after it's own specific flushing functionality.

See also

FlushRequestFilter