class Image (View source)

Provides helpers to operate on images.

Methods

static bool
scaleDimensions(array $dimensions, int $width = NULL, int $height = NULL, bool $upscale = FALSE)

Scales image dimensions while maintaining aspect ratio.

Details

static bool scaleDimensions(array $dimensions, int $width = NULL, int $height = NULL, bool $upscale = FALSE)

Scales image dimensions while maintaining aspect ratio.

The resulting dimensions can be smaller for one or both target dimensions.

Parameters

array $dimensions

Dimensions to be modified - an array with components width and height, in pixels.

int $width

(optional) The target width, in pixels. If this value is NULL then the scaling will be based only on the height value.

int $height

(optional) The target height, in pixels. If this value is NULL then the scaling will be based only on the width value.

bool $upscale

(optional) Boolean indicating that images smaller than the target dimensions will be scaled up. This generally results in a low quality image.

Return Value

bool

TRUE if $dimensions was modified, FALSE otherwise.