trait PadTrait

Trait PadTrait

Methods

gravity(string $compassGravity)

Sets the compass direction.

offsetX(int|float|string $x)

Sets the x offset.

offsetY(int|float|string $y)

Sets the y offset.

offset(int|float|string $x = null, int|float|string $y = null)

Sets the x and y offset.

background(Background|ColorValue|string $background)

Sets the background.

pad(int|float|string|null $width = null, int|float|null $height = null, string|ColorValue $background = null)

Resizes the image to fill the given width and height while retaining the original aspect ratio and with all of the original image visible.

limitPad(int|float|string|null $width = null, int|float|null $height = null, string|ColorValue $background = null)

Same as the Pad::pad mode but only if the original image is larger than the given limit (width and height), in which case the image is scaled down to fill the given width and height while retaining the original aspect ratio and with all of the original image visible.

minimumPad(int|float|string|null $width = null, int|float|null $height = null, string|ColorValue $background = null)

Same as the Pad::pad mode but only if the original image is smaller than the given minimum (width and height), in which case the image is scaled up to fill the given width and height while retaining the original aspect ratio and with all of the original image visible.

position(BasePosition $position)

Sets pad position.

Details

CompassGravityTrait gravity(string $compassGravity)

Sets the compass direction.

The compass direction represents a location in the image, for example, Gravity::northEast() represents the top right corner.

Parameters

Name Type Description
$compassGravity string

Return Value

CompassGravityTrait

See also

Gravity::northEast

$this offsetX(int|float|string $x)

Sets the x offset.

Parameters

Name Type Description
$x int|float|string The x offset.

Return Value

$this

$this offsetY(int|float|string $y)

Sets the y offset.

Parameters

Name Type Description
$y int|float|string The y offset.

Return Value

$this

OffsetTrait offset(int|float|string $x = null, int|float|string $y = null)

Sets the x and y offset.

Parameters

Name Type Description
$x int|float|string The x offset.
$y int|float|string The y offset.

Return Value

OffsetTrait

$this background(Background|ColorValue|string $background)

Sets the background.

The image background is visible when padding is added with one of the padding crop modes, when rounding corners, when adding overlays, and with semi-transparent PNGs and GIFs.

Parameters

Name Type Description
$background Background|ColorValue|string The the background to set.

Return Value

$this

See also

Background

static Pad pad(int|float|string|null $width = null, int|float|null $height = null, string|ColorValue $background = null)

Resizes the image to fill the given width and height while retaining the original aspect ratio and with all of the original image visible.

If the proportions of the original image do not match the given width and height, padding is added to the image to reach the required size

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.
$background string|ColorValue Sets the background color of the image.

Return Value

Pad

static Pad limitPad(int|float|string|null $width = null, int|float|null $height = null, string|ColorValue $background = null)

Same as the Pad::pad mode but only if the original image is larger than the given limit (width and height), in which case the image is scaled down to fill the given width and height while retaining the original aspect ratio and with all of the original image visible.

This mode doesn't scale up the image if your requested dimensions are bigger than the original image's.

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.
$background string|ColorValue Sets the background color of the image.

Return Value

Pad

See also

Pad::pad

static Pad minimumPad(int|float|string|null $width = null, int|float|null $height = null, string|ColorValue $background = null)

Same as the Pad::pad mode but only if the original image is smaller than the given minimum (width and height), in which case the image is scaled up to fill the given width and height while retaining the original aspect ratio and with all of the original image visible.

This mode doesn't scale down the image if your requested dimensions are smaller than the original image's.

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.
$background string|ColorValue Sets the background color of the image.

Return Value

Pad

See also

Pad::pad

$this position(BasePosition $position)

Sets pad position.

Parameters

Name Type Description
$position BasePosition The desired position

Return Value

$this