trait TransformationResizeTrait

Trait TransformationResizeTrait

Here we add the most common 'aliases' for building transformation at the top level

Methods

resize(BaseResizeAction $resize)

Resize the asset using provided resize action

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.

crop(int|float|string|null $width = null, int|float|null $height = null, Gravity $gravity = null, int|float|X $x = null, int|float|Y $y = null)

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

fill(int|float|string|null $width = null, int|float|null $height = null, Gravity $gravity = null)

Creates an image with the exact given width and height without distorting the image.

genericResize(string $name, int|float|string|null $width = null, int|float|null $height = null)

Custom resize builder.

Details

TransformationResizeTrait resize(BaseResizeAction $resize)

Resize the asset using provided resize action

Parameters

Name Type Description
$resize BaseResizeAction The resize action

Return Value

TransformationResizeTrait

TransformationResizeTrait 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

TransformationResizeTrait

TransformationResizeTrait crop(int|float|string|null $width = null, int|float|null $height = null, Gravity $gravity = null, int|float|X $x = null, int|float|Y $y = null)

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

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.
$gravity Gravity Which part of the original image to include.
$x int|float|X Horizontal position for custom-coordinates based cropping
$y int|float|Y Vertical position for custom-coordinates based cropping

Return Value

TransformationResizeTrait

TransformationResizeTrait fill(int|float|string|null $width = null, int|float|null $height = null, Gravity $gravity = null)

Creates an image with the exact given width and height without distorting the image.

This option first scales up or down as much as needed to at least fill both of the given dimensions. If the requested aspect ratio is different than the original, cropping will occur on the dimension that exceeds the requested size after scaling.

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.
$gravity Gravity Which part of the original image to include when the resulting image is smaller than the original or the proportions do not match.

Return Value

TransformationResizeTrait

TransformationResizeTrait genericResize(string $name, int|float|string|null $width = null, int|float|null $height = null)

Custom resize builder.

Parameters

Name Type Description
$name string Provide future (not supported in the current version) resize name
$width int|float|string|null The required width of a transformed asset.
$height int|float|null The required height of a transformed asset.

Return Value

TransformationResizeTrait