trait ImagePixelEffectTrait

Trait ImagePixelEffectTrait

Methods

pixelate(int $squareSize = null)

Applies a pixelation effect to the image.

makeTransparent(int $tolerance = null)

Makes the background of the image transparent (or solid white for formats that do not support transparency).

removeBackground(bool $screen = false, string|Color $colorToRemove = null)

Makes the background of an image transparent (or solid white for JPGs).

backgroundRemoval(bool|null $fineEdges = null, array $hints = [])

Uses the Cloudinary AI Background Removal add-on to make the background of an image transparent.

dither(int $level = null)

Applies an ordered dither filter to the image.

gradientFade(int $strength = null, string $type = null)

Applies a gradient fade effect from the top edge of the image.

cutOut(string|Media $source = null)

Trims pixels according to the transparency levels of a specified overlay image.

Details

static Pixelate pixelate(int $squareSize = null)

Applies a pixelation effect to the image.

Parameters

Name Type Description
$squareSize int The width of each pixelation square in pixels. (Range: 1 to 200, Server default: 5)

Return Value

Pixelate

static MakeTransparent makeTransparent(int $tolerance = null)

Makes the background of the image transparent (or solid white for formats that do not support transparency).

The background is determined as all pixels that resemble the pixels on the edges of the image.

Parameters

Name Type Description
$tolerance int The tolerance used to accommodate variance in the background color. (Range: 0 to 100, Server default: 10)

Return Value

MakeTransparent

static RemoveBackground removeBackground(bool $screen = false, string|Color $colorToRemove = null)

Makes the background of an image transparent (or solid white for JPGs).

Use when the background is a uniform color.

Parameters

Name Type Description
$screen bool When true, provides better results for images with near perfect green/blue background.
$colorToRemove string|Color The background color as an RGB/A hex code. Overrides the algorithm's choice of background color. Default: The algorithm's choice - often the edge color of the image.

Return Value

RemoveBackground

See also

RemoveBackground

static BackgroundRemoval backgroundRemoval(bool|null $fineEdges = null, array $hints = [])

Uses the Cloudinary AI Background Removal add-on to make the background of an image transparent.

Parameters

Name Type Description
$fineEdges bool|null Enables detailed background removal around a foreground object with fine detail around its edges.
$hints array A list of foreground objects to keep.

Return Value

BackgroundRemoval

See also

BackgroundRemoval

static Dither dither(int $level = null)

Applies an ordered dither filter to the image.

Use the constants defined in \Cloudinary\Transformation\OrderedDither for $level.

Parameters

Name Type Description
$level int The level of ordered dither. Use the constants defined in the OrderedDither class.

Return Value

Dither

See also

Dither

static GradientFade gradientFade(int $strength = null, string $type = null)

Applies a gradient fade effect from the top edge of the image.

You can specify other edges using the x and y methods of the \Cloudinary\Transformation\GradientFade class.

Parameters

Name Type Description
$strength int The strength of the fade effect. (Range: 0 to 100, Server default: 20)
$type string The type of gradient fade: GradientFade::SYMMETRIC or GradientFade::SYMMETRIC_PAD.

Return Value

GradientFade

See also

GradientFade

static CutOut cutOut(string|Media $source = null)

Trims pixels according to the transparency levels of a specified overlay image.

Wherever an overlay image is transparent, the original is shown, and wherever an overlay is opaque, the resulting image is transparent.

Parameters

Name Type Description
$source string|Media The public ID of the source.

Return Value

CutOut

See also

CutOut