# Effects

# GD and Imagick

The following basic adjustments works both in GD and Imagick, and are limited to what is available in Imagine:

# blur [int|float|bool]

Blurs the image. If you're using GD as image driver, blur can only be toggled on/off, either with true/false or 1/0.

# colorize [string]

Colorizes the image. Expects a hexadecimal color value.

# gamma [int|float]

Adjusts the image gamma.

# grayscale [bool]

Converts the image to grayscale if set to true.

# negative [bool]

Converts the image to negative if set to true.

# sharpen [bool]

Sharpens the image to grayscale if set to true.

# Imagick only

The following advanced image adjustments are only available when using Imagick:

# adaptiveBlur [array]

Applies an adaptive blur effect to the image. The effect takes an array with two value corresponding to radius and sigma. Example:

{% set transformedImage = craft.imager.transformImage(img, { width: 500, effects: { adaptiveBlur: [10, 2] }}) %}

# adaptiveSharpen [array]

Applies an adaptive sharpen effect to the image. The effect takes an array with two value corresponding to radius and sigma.

# clut [array]

Applies a clut (color lookup table) effect to the image, using Imagick's clutImage method. You probably want to use it together with modulate to get a real duotone effect. Example:

{% set transformedImage = craft.imager.transformImage(image, { width: 500, effects: { modulate: [100, 0, 100], clut: 'gradient:darkblue-aqua' } }) %}

The parameter is the image definition string sent to Imagick's newPseudoImage method. You can use any valid color values. Example with rgba colors:

{% set transformedImage = craft.imager.transformImage(image, { width: 500, effects: { modulate: [100, 0, 100], clut: 'gradient:rgba(255,0,0,0.8)-rgba(255,255,0,1)' } }) %}

Please note that the alpha value doesn't actually make the color transparent, it just has the effect of moving the gradient's center point towards the color with the least transparency.

# colorBlend [array]

Blends the image with the color and opacity specified. Example:

{% set transformedImage = craft.imagerx.transformImage(image, { width: 500, effects: { colorBlend: ['rgb(255, 153, 51)', 0.5] } }) %}

# contrast [bool|int|float]

Increases or decreases the contrast of the image. A value greater than 0 increases contrast while a negative value decreases it.

# contrastStretch [array]

Enhances the contrast of a color image by adjusting the pixels color to span the entire range of colors available. Uses Imagick's contrastStretch method. Example:

{% set transformedImage = craft.imager.transformImage(image, { width: 500, effects: { contrastStretch: [500*500*0.10, 500*500*0.90] } }) %}

# despeckle [bool]

Runs a despeckle routine on the image, using Imagick's despeckleImage method.

# enhance [bool]

Runs an enhance routine on the image, using Imagick's enhanceImage method.

# equalize [bool]

Runs an equalize routine on the image, using Imagick's equalizeImage method.

# levels [array]

Adjusts an image's levels, using Imagick's levelImage method. The effect takes an array corresponding to black point, gamma, white point and channel (optional). Example:

{% set transformedImage = craft.imager.transformImage(img, { width: 500, effects: { levels: [50, 1, 200, 'blue'] }}) %}

You can use negative values for black point and white point to do a level stretch/offset:

{% set transformedImage = craft.imager.transformImage(img, { width: 500, effects: { levels: [-100, 1, 255, 'blue'] }}) %}

Possible values for channel is 'red', 'green', and 'blue'. Omit it all together to adjust levels for all channels.

# modulate [array]

Let's you adjust brightness, saturation and hue with Imagick's modulateImage method. Example (drops saturation by 80%):

{% set transformedImage = craft.imager.transformImage(image, { width: 500, effects: { modulate: [100, 20, 100] } }) %}

# motionBlur [array]

Blurs an image, using Imagick's motionBlurImage method. The effect takes an array with three values, corresponding to radius, sigma and angle. Example:

{% set transformedImage = craft.imager.transformImage(img, { width: 500, effects: { motionBlur: [20, 40, 45] }}) %}

# normalize [bool]

Enhances the contrast of the image by normalizing the colorspace. Uses Imagick's normalizeImage method.

# oilPaint [int]

Creates an oil paint effect, using Imagick's oilPaintImage method.

# opacity [float|array]

Makes the image semi-transparent.

{% set transformedImage = craft.imager.transformImage(image, { width: 500, effects: { opacity: [0.5, '#f00'] } }) %}

Please note, if you pass in 'transparent' as background color, and the image format doesn't support full and partial transparency (ie, it's not png), the filter will have some side-effect. For jpegs no apparent effect will happen. For gifs, the whole image may become transparent (since partial transparency isn't supported). Either pass in the desired backgrond color you want to fade towards, or convert the image to a format that supports transparency.

# posterize [array]

Reduces image colors by applying the posterize effect. Uses Imagick's posterizeImage method. Example:

{% set transformedImage = craft.imager.transformImage(image, { width: 500, effects: { posterize: [136, 'no'] } }) %}

The second parameter refers to which dither method is used. Allowed values are:

'no': No dithering.
'riemersma': Riemersma dithering.
'floydsteinberg': Floyd–Steinberg dithering.

# quantize [array|int]

Reduces the number of colors in an image, using Imagick's quantizeImage method. This can help to reduce filesize, especially for gif images. Example:

{% set transformedImage = craft.imager.transformImage(image, { width: 500, effects: { quantize: 32 } }) %}

The parameter can be an int, indicating the number of colors to reduce to, or an array that corresponds to the functions $numberColors (int), $treedepth (int) and $dither (bool) parameters. Example with default treeDepth, but dithering:

{% set transformedImage = craft.imager.transformImage(image, { width: 500, effects: { quantize: [32, 0, true] } }) %}

# radialBlur [int]

Blurs an image, using Imagick's radialBlurImage method.

# sepia [int]

Converts the image to sepia tones.

# tint [array]

Tints the image using Imagick's tintImage method.

# unsharpmask [array]

Applies an unsharp mask with Imagick's unsharpMaskImage method. Example:

{% set transformedImage = craft.imager.transformImage(image, { width: 500, effects: { unsharpMask: [0, 0.5, 1, 0.05] } }) %}