Operations

A mandatory operation when requesting an image.

This provides a list of optional operations for transforming an image.

Affine#

Perform an affine transform on an image. You must provide a matrix array of length 4 affine transformation matrix.

By default, new pixels are filled with a black background. You can provide a background color with the background option. A particular interpolator may also be specified via the interpolator option.

Options#

KeyTypeOptionalDefault
matrixArray(Number)xn/a
idxIntegern/a
idyIntegern/a
odxIntegern/a
odyIntegern/a
interpolatorEnum(Interpolator)n/a

Example#

{ "operation": "affine", "matrix": [1, 0.3, 0.1, 0.7] }

Blur#

Blur the image. When used without options, performs a fast, mild blur of the output image.

When a sigma is provided, performs a slower, more accurate Gaussian blur.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
sigmaFloat0.31000n/a

Example#

{ "operation": "blur", "sigma": 10 }

Clahe#

Perform contrast limiting adaptive histogram equalization (CLAHE)

This will, in general, enhance the clarity of the image by bringing out darker details.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
widthIntegerx1n/an/a
heightIntegerx1n/an/a
maxSlopeInteger0100n/a

Example#

{ "operation": "clahe", "width": 3, "height": 3 }

Colorspace#

Output colourspace e.g. srgb, rgb, cmyk, lab, b-w ...

Options#

KeyTypeOptionalMin ValueMax ValueDefault
colorspaceEnum(Colorspace)xn/an/an/a

Composite#

Composite an image over the base image. The image to composite must be the same size or smaller than the base image.

If both top and left options are provided, they take precedence over gravity.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
inputstringxn/an/an/a
blendEnum(Blend)n/an/aover
gravityEnum(Gravity)n/an/an/a
topIntegern/an/an/a
leftIntegern/an/an/a
tileBooleann/an/an/a
premultipliedBooleann/an/an/a
densityIntegern/an/a72

Convolve#

Convolve the image with the specified kernel.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
widthIntegerx31001n/a
heightIntegerx31001n/a
kernelArray(Number)xn/an/an/a
scaleIntegern/an/an/a
offsetIntegern/an/an/a

Example#

{
  "operation": "convolve",
  "width": 3,
  "height": 3,
  "kernel": [-1, 0, 1, -2, 0, 2, -1, 0, 1]
}

Extend#

Extends/pads the edges of the image with the provided background colour.

This operation will always occur after resizing and extraction, if any.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
allIntegern/an/a0
topIntegern/an/a0
leftIntegern/an/a0
bottomIntegern/an/a0
rightIntegern/an/a0
backgroundStringn/an/a'#000'

Example#

{
  "operation": "extend",
  "top": 42,
  "bottom": 84,
  "left": 16,
  "right": 16,
  "background": "#FFA03F"
}

Extract#

Zero-indexed offset in pixels from the top edge.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
topIntegern/an/a0
leftIntegern/an/a0
bottomIntegern/an/a0
rightIntegern/an/a0

Flatten#

Merge alpha transparency channel, if any, with a background, then remove the alpha channel.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
backgroundStringn/an/a'#000'

Flip#

Flip the image about the vertical Y axis.

Options#

No options available

Example#

{ "operation": "flip" }

Flop#

Flop the image about the horizontal X axis.

Options#

No options available

Example#

{ "operation": "flop" }

Gamma#

Apply a gamma correction by reducing the encoding (darken) pre-resize at a factor of 1/gamma then increasing the encoding (brighten) post-resize at a factor of gamma. This can improve the perceived brightness of a resized image in non-linear colour spaces.

JPEG and WebP input images will not take advantage of the shrink-on-load performance optimization when applying a gamma correction.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
gammaNumber1.03.01.0
gammaOutNumber1.03.0n/a

Example#

{ "operation": "gamma", "gamma": 2.2, "gammaOut": 2.2 }

Grayscale#

Apply a gamma correction by reducing the encoding (darken) pre-resize at a factor of 1/gamma then increasing the encoding (brighten) post-resize at a factor of gamma. This can improve the perceived brightness of a resized image in non-linear colour spaces.

JPEG and WebP input images will not take advantage of the shrink-on-load performance optimization when applying a gamma correction.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
grayscaleBooleann/an/atrue

Example#

{ "operation": "grayscale" }

Linear#

Apply the linear formula a * input + b to the image (levels adjustment).

Options#

KeyTypeOptionalMin ValueMax ValueDefault
aFloatn/an/a1.0
bFloatn/an/a0.0

Example#

{ "operation": "linear", "a": 4, "b": 8 }

Median#

Square mask size: size x size.

Note larger sizes can significantly reduce the performance of processing image e.g. a size of 15 on a 500x500 image adds around 1.5s to processing time.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
sizeInteger110003

Example#

{ "operation": "median", "size": 3 }

Modulate#

Transforms the image using brightness, saturation and hue rotation.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
brightnessNumber0n/an/a
saturationNumber0n/an/a
hueNumber0n/an/a
lightnessNumber0n/an/a

Example#

{
  "operation": "modulate",
  "brightness": 0.5,
  "saturation": 0.5,
  "hue": 90
}

Negate#

Produce a "negative" of the image.

Options#

No options available

Example#

{ "operation": "negate" }

Recomb#

Transforms the image using brightness, saturation and hue rotation.

The matrix option is an array of 3 arrays with 3 numbers values.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
matrixArray(Array(Integer))xn/an/an/a

Example#

{
  "operation": "recomb",
  "matrix": [
    [0.3588, 0.7044, 0.1368],
    [0.299, 0.587, 0.114],
    [0.2392, 0.4696, 0.0912]
  ]
}

Resize#

How the image should be resized to fit both provided dimensions.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
widthNumber0n/an/a
heightNumber0n/an/a
fitEnum(OperationResizeFit)n/an/a'cover'
positionEnum(OperationResizePosition)n/an/a'center'
backgroundStringn/an/a'#000'
kernelEnum(OperationResizeKernel)n/an/a'lanczos3'
withoutEnlargementBooleann/an/afalse
fastShrinkOnLoadBooleann/an/atrue

Rotate#

Rotate the output image by either an explicit angle or auto-orient based on the EXIF Orientation tag.

If an angle is provided, it is converted to a valid positive degree rotation. For example, -450 will produce a 270deg rotation. When rotating by an angle other than a multiple of 90, the background colour can be provided with the background option. If no angle is provided, it is determined from the EXIF data.

Mirroring is supported and may infer the use of a flip operation. The use of rotate implies the removal of the EXIF Orientation tag, if any.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
angleIntegern/an/an/a

Example#

{ "operation": "rotate", "angle": 20 }

Sharpen#

Sharpen the image. When used without parameters, performs a fast, mild sharpen of the output image.

When a sigma is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.

Separate control over the level of sharpening in "flat" and "jagged" areas is available.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
sigmaInteger0.011000n/a
flatInteger0100001.0
jaggedInteger0100002.0

Example#

{ "operation": "sharpen", "sigma": 1000 }

Text#

Sharpen the image. When used without parameters, performs a fast, mild sharpen of the output image.

When a sigma is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.

Separate control over the level of sharpening in "flat" and "jagged" areas is available.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
fontString0.01100030px sans-serif
textAlignEnum(textAlign)n/an/an/a
textColorStringn/an/awhite
backgroundColorStringn/an/an/a
strokeWidthIntegern/an/a0
strokeColorStringn/an/awhite
paddingIntegern/an/a0
borderWidthIntegern/an/a0
borderColorStringn/an/ablack
wrapBooleann/an/an/a
maxWidthIntegern/an/an/a
blendEnum(Blend)n/an/a0
gravityEnum(Gravity)n/an/an/a
topIntegern/an/an/a
leftIntegern/an/an/a

Threshhold#

Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
thresholdNumber0255128
grayscaleBooleann/an/an/a

Example#

{ "operation": "threshold", "threshold": 128 }

Tint#

Tint the image using the provided chroma while preserving the image luminance.

An alpha channel if present will be unchanged by the operation.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
rgbStringxn/an/an/a

Trim#

Trim "boring" pixels from all edges that contain values similar to the top-left pixel. Images consisting entirely of a single colour will calculate "boring" using the alpha channel, if any.

Options#

KeyTypeOptionalMin ValueMax ValueDefault
thresholdInteger0n/an/a