trait ImageEffectTrait

Trait ImageEffectTrait

Methods

blackWhite(int $threshold = null)

Converts the image to black and white.

colorize(int $level = null, string $color = null)

Colorizes the image.

grayscale()

Converts the image to gray-scale (multiple shades of gray).

negate()

Negates the image colors (negative).

sepia(int $level = null)

Changes the color scheme of the image to sepia.

assistColorBlind(int $strength = null)

Applies stripes to the image to help people with common color-blind conditions to differentiate between colors that are similar for them.

simulateColorBlind(string $condition = null)

Simulates the way an image would appear to someone with the specified color blind condition.

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.

artisticFilter(string $filter)

Applies the selected artistic filter to the image.

cartoonify(float $lineStrength = null, float|string $colorReduction = null)

Applies a cartoon effect to an image.

styleTransfer(string $source, int $strength = null, bool $preserveColor = null)

Transfers the style of a source artwork to a target photograph using the Neural Artwork Style Transfer add-on.

oilPaint(int $strength = null)

Applies an oil painting effect to the image.

redEye()

Removes red eyes in the image.

advancedRedEye()

Removes red eyes with the Advanced Facial Attribute Detection add-on.

vectorize(int $colors = null, float $detail = null, float $despeckle = null, int $corners = null, int $paths = null)

Vectorizes the image.

outline(string $mode = null, int $width = null, int $blurLevel = null)

Adds an outline to a transparent image.

shadow(int $strength = null, PointValue $position = null, string $color = null)

Adds a shadow to the image.

dropShadow(int $azimuth = null, int $elevation = null, int $spread = null)

Adds a natural looking shadow to an image.

lightroom()

Applies Adobe Lightroom filter.

theme(string $color, integer $photoSensitivity = null)

Changes the main background color to the one specified, as if a 'theme change' was applied (e.g. dark mode vs light mode).

generativeRestore()

Applies a generative restore effect to the asset.

generativeRecolor(string|array $prompt, string $toColor, bool $detectMultiple = null)

Applies a generative recolor effect to the asset.

generativeRemove(string|array $prompt = null, string|array $region = null, bool $detectMultiple = null, bool $removeShadow = null)

Applies a generative remove effect to the asset.

generativeReplace(string $fromPrompt, string $toPrompt, bool $preserveGeometry = null, bool $detectMultiple = null)

Applies a generative replacement effect to the asset.

upscale()

Uses AI-based prediction to add fine detail while upscaling small images.

Details

static ThresholdEffectAction blackWhite(int $threshold = null)

Converts the image to black and white.

Parameters

Name Type Description
$threshold int The balance between black (100) and white (0). (Range: 0 to 100, Server default: 50)

Return Value

ThresholdEffectAction

static Colorize colorize(int $level = null, string $color = null)

Colorizes the image.

Parameters

Name Type Description
$level int The strength of the color. (Range: 0 to 100, Server default: 100)
$color string The color to use for colorization. Specify HTML name or RGB hex code. (Server default: gray)

Return Value

Colorize

static EffectAction grayscale()

Converts the image to gray-scale (multiple shades of gray).

Return Value

EffectAction

static EffectAction negate()

Negates the image colors (negative).

Return Value

EffectAction

static LevelEffectAction sepia(int $level = null)

Changes the color scheme of the image to sepia.

Parameters

Name Type Description
$level int The level of sepia to apply. (Range: 1 to 100, Server default: 80)

Return Value

LevelEffectAction

static AssistColorBlind assistColorBlind(int $strength = null)

Applies stripes to the image to help people with common color-blind conditions to differentiate between colors that are similar for them.

You can replace colors using the xRay() method of the \Cloudinary\Transformation\AssistColorBlind class.

Parameters

Name Type Description
$strength int The strength of the stripes. (Range: 1 to 100, Server default: 10)

Return Value

AssistColorBlind

See also

AssistColorBlind

static SimulateColorBlind simulateColorBlind(string $condition = null)

Simulates the way an image would appear to someone with the specified color blind condition.

For a list of supported color blind conditions see the \Cloudinary\Transformation\SimulateColorBlind class.

Parameters

Name Type Description
$condition string The color blind condition. Use the constants defined in the SimulateColorBlind class.

Return Value

SimulateColorBlind

See also

SimulateColorBlind

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

static mixed artisticFilter(string $filter)

Applies the selected artistic filter to the image.

See the Image Transformations guide for examples of each of the filters.

Parameters

Name Type Description
$filter string The filter to apply. Use the constants defined in the ArtisticFilter class.

Return Value

mixed

See also

ArtisticFilter
https://cloudinary.com/documentation/image_transformations#available_filters

static Cartoonify cartoonify(float $lineStrength = null, float|string $colorReduction = null)

Applies a cartoon effect to an image.

Parameters

Name Type Description
$lineStrength float The thickness of the lines. (Range: 0 to 100, Server default: 50)
$colorReduction float|string The decrease in the number of colors and corresponding saturation boost of the remaining colors. (Range: 0 to 100, Server default: automatically adjusts according to the line_strength value). Higher reduction values result in a less realistic look. Set $colorReduction to Cartoonify::BLACK_WHITE for a black and white cartoon effect.

Return Value

Cartoonify

See also

Cartoonify

static EffectAction styleTransfer(string $source, int $strength = null, bool $preserveColor = null)

Transfers the style of a source artwork to a target photograph using the Neural Artwork Style Transfer add-on.

For details, see the Neural Artwork Style Transfer add-on documentation.

Parameters

Name Type Description
$source string The public ID of the source artwork.
$strength int The strength of the style transfer. Higher numbers result in an output that is more highly influenced by the source artwork style. (Range: 0 to 100, Server default: 100)
$preserveColor bool When true, style elements of the source artwork, such as brush style and texture, are transferred to the target photo, but the prominent colors from the source artwork are not transferred, so the result retains the original colors of the target photo.

Return Value

EffectAction

See also

https://cloudinary.com/documentation/neural_artwork_style_transfer_addon

static StrengthEffectAction oilPaint(int $strength = null)

Applies an oil painting effect to the image.

Parameters

Name Type Description
$strength int The strength of the effect. (Range: 0 to 100, Server default: 30)

Return Value

StrengthEffectAction

static EffectAction redEye()

Removes red eyes in the image.

Return Value

EffectAction

static EffectAction advancedRedEye()

Removes red eyes with the Advanced Facial Attribute Detection add-on.

For details, see the Advanced Facial Attribute Detection add-on documentation.

static Vectorize vectorize(int $colors = null, float $detail = null, float $despeckle = null, int $corners = null, int $paths = null)

Vectorizes the image.

Use the methods in \Cloudinary\Transformation\Vectorize to control different aspects of the vectorize effect.

Notes: * To deliver the image as a vector image, make sure to change the format (or URL extension) to a vector format, such as SVG. However, you can also deliver in a raster format if you just want to get the 'vectorized' graphic effect. * Large images are scaled down to 1000 pixels in the largest dimension before vectorization.

Parameters

Name Type Description
$colors int The number of colors. (Range: 2 to 30, Server default: 10)
$detail float The level of detail. Specify either a percentage of the original image (Range: 0.0 to 1.0) or an absolute number of pixels (Range: 0 to 1000). (Server default: 300)
$despeckle float The size of speckles to suppress. Specify either a percentage of the original image (Range: 0.0 to 1.0) or an absolute number of pixels (Range: 0 to 100, Server default: 2)
$corners int The corner threshold. Specify 100 for no smoothing (polygon corners), 0 for completely smooth corners. (Range: 0 to 100, Default: 25)
$paths int The optimization value. Specify 100 for least optimization and the largest file. (Range: 0 to 100, Server default: 100).

Return Value

Vectorize

See also

Vectorize

static Outline outline(string $mode = null, int $width = null, int $blurLevel = null)

Adds an outline to a transparent image.

For examples, see the Image Transformations guide.

Parameters

Name Type Description
$mode string The type of outline effect. Use the constants defined in the Outline class. (Default: OutlineMode::INNER and OutlineMode::OUTER).
$width int The thickness of the outline in pixels. (Range: 1 to 100, Server default: 5)
$blurLevel int The level of blur of the outline. (Range: 0 to 2000, Server default: 0)

Return Value

Outline

See also

Outline
OutlineMode
https://cloudinary.com/documentation/image_transformations#outline_effects

static Shadow shadow(int $strength = null, PointValue $position = null, string $color = null)

Adds a shadow to the image.

The shadow is offset by the x and y values specified in the $position qualifier.

Parameters

Name Type Description
$strength int The strength of the shadow. (Range: 0 to 100, Server default: 40)
$position PointValue The position of the shadow. (Server default: bottom right)
$color string The color of the shadow (Server default: gray)

Return Value

Shadow

See also

Shadow

static DropShadow dropShadow(int $azimuth = null, int $elevation = null, int $spread = null)

Adds a natural looking shadow to an image.

Parameters

Name Type Description
$azimuth int Value in range 0 - 360 (degrees).
$elevation int Value in range 0 - 90 (degrees).
$spread int Value in range 0 -100.

Return Value

DropShadow

See also

DropShadow

static LightroomEffect lightroom()

Applies Adobe Lightroom filter.

Return Value

LightroomEffect

static ThemeEffect theme(string $color, integer $photoSensitivity = null)

Changes the main background color to the one specified, as if a 'theme change' was applied (e.g. dark mode vs light mode).

Parameters

Name Type Description
$color string The target background color. Specify either the name of a color (e.g. black, lightgray), or an RGB hex value (e.g. f0ebe6).
$photoSensitivity integer The sensitivity to photographic elements of an image. A value of 0 treats the whole image as non-photographic. A value of 200 treats the whole image as photographic, so no theme change is applied. Range: 0 to 200. Default: 100.

Return Value

ThemeEffect

See also

ThemeEffect
ThemeQualifier

static GenerativeEffectAction generativeRestore()

Applies a generative restore effect to the asset.

Return Value

GenerativeEffectAction

static GenerativeRecolor generativeRecolor(string|array $prompt, string $toColor, bool $detectMultiple = null)

Applies a generative recolor effect to the asset.

Parameters

Name Type Description
$prompt string|array Use natural language to describe what you want to affect in the image.
$toColor string The target color.
$detectMultiple bool Whether to recolor all instances of the prompt in the image.

Return Value

GenerativeRecolor

static GenerativeRemove generativeRemove(string|array $prompt = null, string|array $region = null, bool $detectMultiple = null, bool $removeShadow = null)

Applies a generative remove effect to the asset.

Parameters

Name Type Description
$prompt string|array Use natural language to describe what you want to affect in the image.
$region string|array Remove items from the specified region(s).
$detectMultiple bool Whether to detect all instances of the prompt in the image.
$removeShadow bool Whether to remove shadows and reflections.

Return Value

GenerativeRemove

static GenerativeReplace generativeReplace(string $fromPrompt, string $toPrompt, bool $preserveGeometry = null, bool $detectMultiple = null)

Applies a generative replacement effect to the asset.

Parameters

Name Type Description
$fromPrompt string Use natural language to describe what you want to replace.
$toPrompt string Use natural language to describe the replacement.
$preserveGeometry bool Whether to maintain the shape of the object you're replacing.
$detectMultiple bool Whether to detect all instances of the prompt in the image.

Return Value

GenerativeReplace

static GenerativeEffectAction upscale()

Uses AI-based prediction to add fine detail while upscaling small images.

This 'super-resolution' feature scales each dimension by four, multiplying the total number of pixels by 16.

Return Value

GenerativeEffectAction