class Resize extends BaseResizeAction

Determines how to crop, scale, and/or zoom the delivered asset according to the requested dimensions.

Learn more: Resizing images | Resizing videos

Methods

scale(mixed $width = null, mixed $height = null, mixed $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(mixed $width = null, mixed $height = null, mixed $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(mixed $width = null, mixed $height = null, mixed $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(mixed $width = null, mixed $height = null, mixed $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.

crop(mixed $width = null, mixed $height = null, mixed $gravity = null, mixed $x = null, mixed $y = null)

Extracts a region of the given width and height out of the original image.

thumbnail(mixed $width = null, mixed $height = null, mixed $gravity = null, mixed $x = null, mixed $y = null)

The thumb cropping mode is specifically used for creating image thumbnails from either face or custom coordinates, and must always be accompanied by the gravity qualifier set to one of the face detection or custom values.

auto(mixed $width = null, mixed $height = null, AutoGravity|null $gravity = null)

Automatically determines the best crop based on the gravity and specified dimensions.

Details

static Scale scale(mixed $width = null, mixed $height = null, mixed $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 mixed The required width of a transformed asset.
$height mixed The required height of a transformed asset.
$aspectRatio mixed Resizes the asset to a new aspect ratio.

Return Value

Scale

static Scale fit(mixed $width = null, mixed $height = null, mixed $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 mixed The required width of a transformed asset.
$height mixed The required height of a transformed asset.
$aspectRatio mixed Resizes the asset to a new aspect ratio.

Return Value

Scale

static Scale limitFit(mixed $width = null, mixed $height = null, mixed $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 mixed The required width of a transformed asset.
$height mixed The required height of a transformed asset.
$aspectRatio mixed Resizes the asset to a new aspect ratio.

Return Value

Scale

See also

Scale::fit

static Scale minimumFit(mixed $width = null, mixed $height = null, mixed $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 mixed The required width of a transformed asset.
$height mixed The required height of a transformed asset.
$aspectRatio mixed Resizes the asset to a new aspect ratio.

Return Value

Scale

See also

Scale::fit

static Crop crop(mixed $width = null, mixed $height = null, mixed $gravity = null, mixed $x = null, mixed $y = null)

Extracts a region of the given width and height out of the original image.

Parameters

Name Type Description
$width mixed The required width of a transformed asset.
$height mixed The required height of a transformed asset.
$gravity mixed Which part of the original image to include.
$x mixed Horizontal position for custom-coordinates based cropping
$y mixed Vertical position for custom-coordinates based cropping

Return Value

Crop

static Crop thumbnail(mixed $width = null, mixed $height = null, mixed $gravity = null, mixed $x = null, mixed $y = null)

The thumb cropping mode is specifically used for creating image thumbnails from either face or custom coordinates, and must always be accompanied by the gravity qualifier set to one of the face detection or custom values.

Parameters

Name Type Description
$width mixed The required width of a transformed asset.
$height mixed The required height of a transformed asset.
$gravity mixed Which part of the original image to include.
$x mixed Horizontal position for custom-coordinates based cropping
$y mixed Vertical position for custom-coordinates based cropping

Return Value

Crop

static Crop auto(mixed $width = null, mixed $height = null, AutoGravity|null $gravity = null)

Automatically determines the best crop based on the gravity and specified dimensions.

If the requested dimensions are smaller than the best crop, the result is downscaled. If the requested dimensions are larger than the original image, the result is upscaled. Use this mode in conjunction with the g (gravity) parameter.

Parameters

Name Type Description
$width mixed The required width of a transformed asset.
$height mixed The required height of a transformed asset.
$gravity AutoGravity|null Which part of the original image to include.

Return Value

Crop