interface Image_Backend

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

__construct(AssetContainer $assetContainer = null)

Create a new backend with the given object

int
getWidth()

No description

int
getHeight()

No description

loadFromContainer(AssetContainer $assetContainer)

Populate the backend with a given object

loadFrom(string $path)

Populate the backend from a local path

mixed
getImageResource()

Get the currently assigned image resource

setImageResource(mixed $resource)

Set the currently assigned image resource

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

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.

Details

at line 36
__construct(AssetContainer $assetContainer = null)

Create a new backend with the given object

Parameters

AssetContainer $assetContainer Object to load from

at line 41
int getWidth()

Return Value

int The width of the image

at line 46
int getHeight()

Return Value

int The height of the image

at line 53
loadFromContainer(AssetContainer $assetContainer)

Populate the backend with a given object

Parameters

AssetContainer $assetContainer Object to load from

at line 60
loadFrom(string $path)

Populate the backend from a local path

Parameters

string $path

at line 67
mixed getImageResource()

Get the currently assigned image resource

Return Value

mixed

at line 74
setImageResource(mixed $resource)

Set the currently assigned image resource

Parameters

mixed $resource

at line 87
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.

at line 95
bool writeTo(string $path)

Write the backend to a local path

Parameters

string $path

Return Value

bool if the write was successful

at line 102
setQuality(int $quality)

Set the quality to a value between 0 and 100

Parameters

int $quality

at line 111
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 123
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 131
Image_Backend resizeByWidth(int $width)

Resize an image by width. Preserves aspect ratio.

Parameters

int $width

Return Value

Image_Backend

at line 139
Image_Backend resizeByHeight(int $height)

Resize an image by height. Preserves aspect ratio.

Parameters

int $height

Return Value

Image_Backend

at line 150
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 159
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 169
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