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#
Key | Type | Optional | Default |
---|---|---|---|
matrix | Array(Number) | x | n/a |
idx | Integer | ✓ | n/a |
idy | Integer | ✓ | n/a |
odx | Integer | ✓ | n/a |
ody | Integer | ✓ | n/a |
interpolator | Enum(Interpolator) | ✓ | n/a |
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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
sigma | Float | ✓ | 0.3 | 1000 | n/a |
Options#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
width | Integer | x | 1 | n/a | n/a |
height | Integer | x | 1 | n/a | n/a |
maxSlope | Integer | ✓ | 0 | 100 | n/a |
Colorspace
#
Output colourspace e.g. srgb, rgb, cmyk, lab, b-w ...
Options#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
colorspace | Enum(Colorspace) | x | n/a | n/a | n/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
.
Convolve
#
Convolve the image with the specified kernel.
Options#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
width | Integer | x | 3 | 1001 | n/a |
height | Integer | x | 3 | 1001 | n/a |
kernel | Array(Number) | x | n/a | n/a | n/a |
scale | Integer | ✓ | n/a | n/a | n/a |
offset | Integer | ✓ | n/a | n/a | n/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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
all | Integer | ✓ | n/a | n/a | 0 |
top | Integer | ✓ | n/a | n/a | 0 |
left | Integer | ✓ | n/a | n/a | 0 |
bottom | Integer | ✓ | n/a | n/a | 0 |
right | Integer | ✓ | n/a | n/a | 0 |
background | String | ✓ | n/a | n/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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
top | Integer | ✓ | n/a | n/a | 0 |
left | Integer | ✓ | n/a | n/a | 0 |
bottom | Integer | ✓ | n/a | n/a | 0 |
right | Integer | ✓ | n/a | n/a | 0 |
Flatten
#
Merge alpha transparency channel, if any, with a background, then remove the alpha channel.
Options#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
background | String | ✓ | n/a | n/a | '#000' |
Flip
#
Flip the image about the vertical Y axis.
Options#
No options available
Flop
#
Flop the image about the horizontal X axis.
Options#
No options available
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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
gamma | Number | ✓ | 1.0 | 3.0 | 1.0 |
gammaOut | Number | ✓ | 1.0 | 3.0 | n/a |
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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
grayscale | Boolean | ✓ | n/a | n/a | true |
Linear
#
Apply the linear formula a * input + b to the image (levels adjustment).
Options#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
a | Float | ✓ | n/a | n/a | 1.0 |
b | Float | ✓ | n/a | n/a | 0.0 |
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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
size | Integer | ✓ | 1 | 1000 | 3 |
Modulate
#
Transforms the image using brightness, saturation and hue rotation.
Options#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
brightness | Number | ✓ | 0 | n/a | n/a |
saturation | Number | ✓ | 0 | n/a | n/a |
hue | Number | ✓ | 0 | n/a | n/a |
lightness | Number | ✓ | 0 | n/a | n/a |
Negate
#
Produce a "negative" of the image.
Options#
No options available
Recomb
#
Transforms the image using brightness, saturation and hue rotation.
The matrix
option is an array of 3 arrays with 3 numbers values.
Options#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
matrix | Array(Array(Integer)) | x | n/a | n/a | n/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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
width | Number | ✓ | 0 | n/a | n/a |
height | Number | ✓ | 0 | n/a | n/a |
fit | Enum(OperationResizeFit) | ✓ | n/a | n/a | 'cover' |
position | Enum(OperationResizePosition) | ✓ | n/a | n/a | 'center' |
background | String | ✓ | n/a | n/a | '#000' |
kernel | Enum(OperationResizeKernel) | ✓ | n/a | n/a | 'lanczos3' |
withoutEnlargement | Boolean | ✓ | n/a | n/a | false |
fastShrinkOnLoad | Boolean | ✓ | n/a | n/a | true |
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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
angle | Integer | ✓ | n/a | n/a | n/a |
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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
sigma | Integer | ✓ | 0.01 | 1000 | n/a |
flat | Integer | ✓ | 0 | 10000 | 1.0 |
jagged | Integer | ✓ | 0 | 10000 | 2.0 |
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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
font | String | ✓ | 0.01 | 1000 | 30px sans-serif |
textAlign | Enum(textAlign) | ✓ | n/a | n/a | n/a |
textColor | String | ✓ | n/a | n/a | white |
backgroundColor | String | ✓ | n/a | n/a | n/a |
strokeWidth | Integer | ✓ | n/a | n/a | 0 |
strokeColor | String | ✓ | n/a | n/a | white |
padding | Integer | ✓ | n/a | n/a | 0 |
borderWidth | Integer | ✓ | n/a | n/a | 0 |
borderColor | String | ✓ | n/a | n/a | black |
wrap | Boolean | ✓ | n/a | n/a | n/a |
maxWidth | Integer | ✓ | n/a | n/a | n/a |
blend | Enum(Blend) | ✓ | n/a | n/a | 0 |
gravity | Enum(Gravity) | ✓ | n/a | n/a | n/a |
top | Integer | ✓ | n/a | n/a | n/a |
left | Integer | ✓ | n/a | n/a | n/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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
threshold | Number | ✓ | 0 | 255 | 128 |
grayscale | Boolean | ✓ | n/a | n/a | n/a |
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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
rgb | String | x | n/a | n/a | n/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#
Key | Type | Optional | Min Value | Max Value | Default |
---|---|---|---|---|---|
threshold | Integer | ✓ | 0 | n/a | n/a |