trait ScaleTrait

Trait ScaleTrait

Methods

scale(int|float|string|null $width = null, int|float|null $height = null, int|float|array $aspectRatio = null)

Change the size of the image exactly to the given width and height without necessarily retaining the original aspect ratio: all original image parts are visible but might be stretched or shrunk.

fit(int|float|string|null $width = null, int|float|null $height = null, int|float|array $aspectRatio = null)

The image is resized so that it takes up as much space as possible within a bounding box defined by the given width and height qualifiers. The original aspect ratio is retained and all of the original image is visible.

limitFit(int|float|string $width = null, int|float $height = null, int|float|array $aspectRatio = null)

Same as the Scale::fit mode but only if the original image is larger than the given limit (width and height), in which case the image is scaled down so that it takes up as much space as possible within a bounding box defined by the given width and height qualifiers. The original aspect ratio is retained and all of the original image is visible.

minimumFit(int|float|string|null $width = null, int|float|null $height = null, int|float|array $aspectRatio = null)

Same as the Scale::fit mode but only if the original image is smaller than the given minimum (width and height), in which case the image is scaled up so that it takes up as much space as possible within a bounding box defined by the given width and height qualifiers. The original aspect ratio is retained and all of the original image is visible.

Details

static Scale scale(int|float|string|null $width = null, int|float|null $height = null, int|float|array $aspectRatio = null)

Change the size of the image exactly to the given width and height without necessarily retaining the original aspect ratio: all original image parts are visible but might be stretched or shrunk.

Parameters

Name Type Description
$width int|float|string|null The required width of a transformed asset.
$height int|float|null The required height of a transformed asset.
$aspectRatio int|float|array Resizes the asset to a new aspect ratio.

Return Value

Scale

static Scale fit(int|float|string|null $width = null, int|float|null $height = null, int|float|array $aspectRatio = null)

The image is resized so that it takes up as much space as possible within a bounding box defined by the given width and height qualifiers. The original aspect ratio is retained and all of the original image is visible.

Parameters

Name Type Description
$width int|float|string|null The required width of a transformed asset.
$height int|float|null The required height of a transformed asset.
$aspectRatio int|float|array Resizes the asset to a new aspect ratio.

Return Value

Scale

static Scale limitFit(int|float|string $width = null, int|float $height = null, int|float|array $aspectRatio = null)

Same as the Scale::fit mode but only if the original image is larger than the given limit (width and height), in which case the image is scaled down so that it takes up as much space as possible within a bounding box defined by the given width and height qualifiers. The original aspect ratio is retained and all of the original image is visible.

Parameters

Name Type Description
$width int|float|string The required width of a transformed asset.
$height int|float The required height of a transformed asset.
$aspectRatio int|float|array Resizes the asset to a new aspect ratio.

Return Value

Scale

See also

Scale::fit

static Scale minimumFit(int|float|string|null $width = null, int|float|null $height = null, int|float|array $aspectRatio = null)

Same as the Scale::fit mode but only if the original image is smaller than the given minimum (width and height), in which case the image is scaled up so that it takes up as much space as possible within a bounding box defined by the given width and height qualifiers. The original aspect ratio is retained and all of the original image is visible.

Parameters

Name Type Description
$width int|float|string|null The required width of a transformed asset.
$height int|float|null The required height of a transformed asset.
$aspectRatio int|float|array Resizes the asset to a new aspect ratio.

Return Value

Scale

See also

Scale::fit