Every transform below goes in the transform query parameter. Chain them with ; and they run in order, for example smartCrop:400x400;radius:max;format:auto. Up to 20 transforms can be chained. Overlay and text layers draw a logo, a watermark or a caption on top.
A transform that is not written correctly, or that would make the image too large, is answered with a 400 and a JSON body whose message says what is wrong. Numbers past a transform's range are clamped to it. Sources larger than about 67 megapixels cannot be transformed. GIF, SVG and other files that are not JPEG, PNG, WebP, BMP or TIFF are served unchanged.
The resize transform allows you to alter the size of any image. This allows you to reduce the amount of data a user will need to download by serving images of the exact size you need.
The full format of resize is shown below - we will go over each part in more detail afterwards.
1?transform=resize:200x100~position:top~fit:contain~background:blue
Specify the dimensions of the image. If you only specify one of the dimensions we will maintain the aspect ratio.
1 2 3 4 5 6 7 8?transform=resize:100x100 // If you only want to specify a single dimension // then use an _ as a placeholder ?transform=resize:_x100 ?transform=resize:100x_
When changing the size of an image there are many strategies that can be used to"fit" the image into the space. The strategy can be given using the
fitPossible fit options are:
1?transform=resize:200x100~fit:contain
Move where the image is in the canvas. Possible values include:
1?transform=resize:200x100~position:top
When resizing an image you may get into a scenario where there is blank space on some sides of the new image. By default this blank space will be transparent (for JPEG files it will be white). You can customize this with the background option:
background1?transform=resize:200x100~background:hex(ff0000)
With the default cover fit, part of the image is cut off. Give a focus point to choose what stays in view: ~focus:X,Y in pixels or percent of the original image. The crop is centred on the point as far as the image edges allow.
1?transform=resize:200x200~focus:80pc,30pc
Add ~upscale:false and a small original is never made bigger than it is, which is what you want for responsive images. When the fit would have scaled it up, the box shrinks by the same amount instead, so cover still crops to the box's shape and contain still pads in proportion. With one side free, the image keeps its own size.
1?transform=resize:1600x_~upscale:false
Width and height are capped at 4000px. A resize that is not written correctly is answered with a 400 and a JSON body whose message says what is wrong:
| resize:300 | The size must be WIDTHxHEIGHT, with _ for a free side. |
| resize:_x_ | At least one of width and height is needed. |
| resize:-10x10, resize:1.5x10 | Sizes must be positive whole numbers. |
| resize:10x10~fit | Every option needs a value. |
| resize:10x10~color:red | Unknown option. |
| resize:_x100~fit:inside | Inside and outside need both sides. |
| resize:10x10~fit:contain~focus:1,1 | Focus only works with fit cover. |
| resize:10x10~upscale:no | Upscale is true or false. |
The resizeAR transform is very similar to the resize transform with the only exception being instead of setting the width and height you set the desired aspect ratio.
All of the options that can be supplied to the resize transforms can be given to the resizeAR transform. For details of the options, please refer to the resize transform documentation.
1?transform=resizeAR:16x9
Extract a section of the image, specifying the width and height of the area to extract.
crop:50pcx50pc.In addition to specifying the size of the crop area, you can also specify its placement. The placement can be given in px or percent (pc) and defines where the center of the crop area is. The crop area will always be within the original image meaning if the placement is outside of the bounds it may be adjusted.
Instead of a placement you can anchor the crop to an edge or corner with ~position:, using the same positions as resize.
1?transform=crop:50x50
1?transform=crop:200x100~position:top-right
1?transform=crop:50x50@100,50pc
Crop to the most interesting part of the image at the width and height you give. The image is scaled to cover the size, like resize with fit cover, and the crop is moved to where there is the most detail, colour and skin tone instead of the centre.
It looks at edges, colour and skin tones on a small copy of the image, so it is fast and always gives the same result. An image with no stand-out area is cropped from the centre.
1?transform=smartCrop:50x50
Rotate the image clockwise by any number of degrees. Negative angles turn it anticlockwise. Multiples of 90 are exact; other angles make the image larger to fit the corners.
type: number
1?transform=rotate:20
When rotating, unless using angles of 90, 180, or 270 the produced image will have a visible background. By default this blank space is transparent (white for JPEG and BMP, which cannot be transparent). The colour of the background can be customised.
background1?transform=rotate:20~background:red
Flip the image on the X or Y axis, or both.
type: x, y, xy
1?transform=flip:x
Round the corners by a radius in pixels, or use max to cut a circle (an ellipse on a rectangle). Crop to a square first for a round avatar. Edges are anti-aliased.
~background: or a background transform earlier in the chain.type: number, max
1?transform=radius:40
1?transform=smartCrop:300x300;radius:max;format:png
Add space around the image. Give one number for every side, two for vertical and horizontal, or four for top, right, bottom and left (like CSS). The space uses ~background:, then any earlier background transform, then transparent (white for JPEG). Each side is at most 2000px.
type: number, v,h, top,right,bottom,left
1?transform=pad:20,40~background:white
Add a solid border of the given width in pixels around the outside of the image. The colour defaults to black.
type: number
min: 0
max: 1000
1?transform=border:8~color:white
Cut away a plain border, such as the white space around a product photo or a scan. The border colour is the top-left pixel's unless you give one with ~color:. The number is the tolerance from 0 to 100 (default 10): how different a pixel can be and still count as border.
trim;pad:24~background:white.type: number
min: 0
max: 100
1?transform=trim:10~color:white
Serve sharp images on high density screens without changing your sizes: dpr:2 doubles every pixel size in the chain (resize, crop, smartCrop, pad, border and radius). It can go anywhere in the chain and takes 0.1 to 5.
type: number
min: 0.1
max: 5
1?transform=resize:300x_;dpr:2
Apply a Gaussian blur. The amount is the blur radius (sigma) in pixels, from 0 (no blur) to 100. Larger values are treated as 100.
type: number
min: 0
max: 100
1?transform=blur:10
Remove all colour. greyscale works too.
1?transform=grayscale
Change the saturation of the image. The amount multiplies it: 0 is greyscale, 1 leaves the image unchanged and 2 doubles it. Values above 10 are treated as 10.
type: number
min: 0
max: 10
1?transform=saturate:1.5
brightness lightens or darkens and contrast increases or reduces the difference between light and dark. Both take -100 to 100, where 0 leaves the image unchanged.
type: number
min: -100
max: 100
1?transform=brightness:15;contrast:20
Rotate every colour round the colour wheel by a number of degrees.
type: number
1?transform=hue:90
Adjust the midtones without clipping the highlights or shadows. Above 1 lightens, below 1 darkens.
type: number
min: 0.1
max: 10
1?transform=gamma:1.5
Give the image a warm, old photograph look. The amount is from 0 to 100 and defaults to 100.
type: number
min: 0
max: 100
1?transform=sepia
Give the image the hue of a colour while keeping its light and shade. The colour's alpha sets the strength, so tint:hex(ff000080) is a half strength red tint.
type: color
1?transform=tint:hex(ff0000)
Make the image see-through. The amount is from 0 (invisible) to 100 (unchanged).
type: number
min: 0
max: 100
1?transform=opacity:50;format:png
Turn the image into square blocks of the given size in pixels, from 1 to 200.
type: number
min: 1
max: 200
1?transform=pixelate:12
Create a negative of the image.
1?transform=invert
Draw another image on top, such as a logo, a badge or a watermark. The overlay is an image file in the same app, given by its id: Fileboy never fetches an image from a URL. Transparent parts of a PNG or WebP overlay let the image show through.
overlay:FILE_ID~width:20pc~position:bottom-right~x:24~y:24~opacity:80
width and height: the overlay's size, in pixels or a percentage of the image (20pc is a fifth of its width). Give one and the overlay keeps its shape; give both and it fits inside that box. Leave both out to draw it at its own size.transform:(…): transforms that run on the overlay first, written like any chain: transform:(resize:200x200~fit:cover;radius:max;grayscale). Format, palette, quality, dpr, strip, background and other layers belong in the main chain. Up to 10, and they count towards the limit of 20.Overlays and text both take these options as well:
position: the corner, edge or centre the layer is anchored to: center (the default), top, bottom, left, right, top-left, top-right, bottom-left or bottom-right.x and y: move the layer in from that edge, in pixels or a percentage of the image (5pc). From the centre, or along the middle of an edge, they move it right and down. Negative values move it the other way, and anything past the edge is cut off.opacity: 0 to 100 (default 100).rotate: degrees clockwise, applied after the layer is sized.tile:true repeats the layer across the whole image, lined up with where one copy would go, for a watermark pattern. gap is the space between copies, in pixels or a percentage of the image's width. A pattern can have up to 2,500 copies.1?transform=overlay:3f2a9c1e-7b4d-4e8a-9c6f-1d2e3f4a5b6c~width:20pc~position:bottom-right~x:24~y:24~opacity:80
1?transform=overlay:3f2a9c1e-7b4d-4e8a-9c6f-1d2e3f4a5b6c~width:120~opacity:25~rotate:-30~tile:true~gap:60~transform:(grayscale)
Write text on top: a caption, a photo credit or a repeated watermark. The text comes first and is URL-encoded inside the transform, so %20 is a space, %3B a ;, %7E a ~, %25 a % and %0A a new line. In the URL itself that encoding is encoded again (%2520); the SDKs do both for you.
font: sans (the default), sans-bold, sans-italic, mono or mono-bold. These are the Go fonts, which cover Latin, Greek and Cyrillic; other scripts and emoji show as boxes.size: pixels (default 32), or a percentage of the image's height (5pc) so it scales with the image.color: default black. background fills a box behind the text, with padding pixels around it. Colours with alpha work for both.wrap: lines wider than this break at spaces, in pixels or a percentage of the image's width. align lines up the lines: left, center or right.position, x, y, opacity, rotate, tile and gap, as for overlays.1?transform=text:%C2%A9%20Jane%20Doe~size:4pc~color:white~background:hex(00000080)~padding:8~position:bottom-left~x:16~y:16
1?transform=text:DRAFT~font:sans-bold~size:8pc~color:rgba(255,255,255,0.5)~rotate:-30~tile:true~gap:40
Change the file format. auto picks the smallest format the browser says it accepts in its Accept header: AVIF, then WebP, then the original format (BMP and TIFF become PNG). Every current browser sends that header for images, so a plain <img> tag is enough. Each outcome is cached separately and the response sends Vary: Accept, so a CDN in front keeps them apart too.
avif asks for AVIF whatever the browser accepts, except for very large images, which come back as WebP (see below). AVIF is usually the smallest: in our tests, photos came out about 30% smaller than WebP at the same visual quality, and graphics and smooth gradients up to half the size. It keeps transparency exactly. quality means the same in every format, so quality:75 as AVIF looks about as good as quality:75 as WebP.
AVIF is slow to make, so an image over 16 megapixels (4096 × 4096) is sent as WebP instead, for auto and avif alike, and the response's Content-Type says which you got. With lossless in the chain, auto picks WebP over AVIF, because lossless WebP is the smaller. Animated GIF and WebP files cannot be transformed, so they are served as they are, still animated.
type: auto, avif, webp, jpeg, png, tiff, bmp
1?transform=format:auto
format:json answers with the size of the image instead of the image: the width and height after the other transforms, and the original's size, format and file size. Use it to reserve space for an image before it loads, or to check an upload.
{
"width": 300,
"height": 200,
"original": { "width": 1200, "height": 800, "format": "image/jpeg", "bytes": 254311 }
}1?transform=resize:300x_;format:json
palette answers with the main colours of the image instead of the image: the dominant colour, up to 16 colours with their share of the image, vibrant and muted swatches, and a black or white text colour for each that meets WCAG AA. On its own it describes the original and is answered from the palette stored with the file. After other transforms it describes their result, so crop first to get the colours of part of the image. After an overlay or text it includes what they drew, and needs a signed URL whenever the overlay does.
{
"dominant": { "hex": "#2f5d8a", "rgb": [47, 93, 138], "share": 0.42, "text": "#ffffff", "contrast": 6.88 },
"colors": [ ... ],
"swatches": { "vibrant": { ... }, "darkMuted": { ... }, "lightVibrant": null, ... },
"transparentShare": 0
}palette:css answers with CSS custom properties and classes instead. ~colors: sets how many colours are listed (0 to 16, default 6) and ~prefix: names the CSS. See Colour palettes for every field.
format and palette comes last decides what the response is. Files that are not JPEG, PNG, WebP, BMP or TIFF are answered with a 422.1?transform=palette~colors:4
Make WebP or AVIF output lossless: every pixel is kept exactly, at the cost of a bigger file. It suits screenshots, diagrams and logos. PNG, TIFF and BMP are always lossless, and JPEG cannot be, so it only changes WebP and AVIF. Lossless WebP is usually smaller than lossless AVIF, so format:auto picks WebP for a lossless chain.
1?transform=format:webp;lossless
Reduce the file size of an image by sacrificing quality. Smaller file sizes will help improve load times on your application especially for slower connections.
type: integer between 0 and 100
1?transform=quality:50
The background transform does nothing in and of itself, but rather it affects all other transforms which utilize a background option such as resize or rotate. The background transform will set the default background color for these transforms enabling you to remove possible duplication.
type: color
min: 0
max: 20
1?transform=background:hex(ff0000)
Re-encode the image without changing it, which removes EXIF (including GPS location), ICC profiles and other metadata. Every transform already does this; use strip when you want nothing else changed.
1?transform=strip