Image Optimization API
Parameter Reference
Learn how each query parameter affects your image.
Adjustments
Name | Description | Parameter | Accepted values | Example |
---|---|---|---|---|
Brightness | Adjusts the image brightness. | bri | Numbers between -100 and +100 , where 0 represents no change. | bri=35 |
Contrast | Adjusts the image contrast. | con | Numbers between -100 and +100 , where 0 represents no change. | con=25 |
Gamma | Adjusts the image gamma. | gam | Numbers between 0.1 and 9.99 . | gam=0.5 |
Sharpen | Sharpen the image. | sharp | Numbers between 0 and 100 . | sharp=50 |
Background
Name | Description | Parameter | Accepted values | Example |
---|---|---|---|---|
Background | Sets the background colour of the image. | bg | 3 digit RGB | bg=222 |
4 digit ARGB (alpha) | bg=5DDD | |||
6 digit RGB | bg=E0FC4A | |||
8 digit ARGB (alpha) | bg=55E0FC4A | |||
Any of the 140 colour names supported by all modern browsers. | bg=darkblue |
Border
Name | Description | Parameter | Accepted values | Example |
---|---|---|---|---|
Border | Add a border to the image. | border | Must use the format width,color,method | border=15,00d6b4,shrink |
Width
Sets the border width in pixels, or using relative dimensions.
Relative dimensions allow you to specify a width or height value as a percentage of the main image.
To use a relative dimension, simply provide a percentage as a number (between 0
and 100
), followed by a w
(width) or h
(height). For example, 5w
represents 5% of the width of the main image.
Color
Sets the border colour - see the background parameter for accepted values.
Method
Sets how the border will be displayed. Available options:
overlay
: Place border on top of image (default).shrink
: Shrink image within border (canvas does not change).expand
: Expands canvas to accommodate border.
Crop
Cropping is mostly done with the fit
parameter, but you can also do a lot more with it than just cropping. Read more about the fit
parameter here.
Name | Description | Parameter | Accepted values | Example |
---|---|---|---|---|
Fitted Crop | Crops the image based on what w or h values you set. | fit | crop | fit=crop&h=250&w=250 |
Position | You can also set where the image is cropped by adding a crop position. | fit | One of: crop-top-left , crop-top , crop-top-right , crop-left , crop-center , crop-right , crop-bottom-left , crop-bottom , crop-bottom-right Default is crop-center , and is the same as crop . | fit=crop-top |
Focal Point | Be specific about the exact crop position using a focal point. | fit | Use two offset percentages: crop-x%-y% . | fit=crop-25-75 |
Zoom | Zoom into your focal point by providing a third value: a float between 1 and 100 . Each full step is the equivalent of a 100% zoom. (eg. x%-y%-2 is the equivalent of viewing the image at 200%). | fit | The suggested range is 1 -10 e.g. crop-x%-y%-2 . | fit=crop-75-25-2 |
Crop | Crops the image to specific dimensions prior to any other resize operations. | crop | Required format: width,height,x,y | crop=900,1400,3000,1600 |
DPR
The device pixel ratio is used to easily convert between CSS pixels and device pixels.
This makes it possible to display images at the correct pixel density on a variety of devices such as Apple devices with Retina Displays and Android devices.
You must specify either a width, a height, or both for this parameter to work.
Name | Description | Parameter | Accepted values | Example |
---|---|---|---|---|
DPR | Display images at the correct pixel density. | dpr | Numbers between 1 and 8 . Default is 1 . | dpr=3 |
Effects
Name | Description | Parameter | Accepted values | Example |
---|---|---|---|---|
Blur | Adds a blur effect to the image. | blur | Numbers between 0 and 100 | blur=15 |
Pixelate | Applies a pixelation effect to the image. | pixel | Numbers between 0 and 1000 . | pixel=25 |
Filter | Applies a filter effect to the image. | filt | greyscale or sepia | filt=sepia |
Encode
Name | Description | Parameter | Accepted values | Example |
---|---|---|---|---|
Quality | Defines the quality of the image. | q | Numbers between 0 and 100 . Defaults to 90 . Only relevant if the format is set to jpg , pjpg , webp or avif . | q=5 |
Format | Encodes the image to a specific format. | fm | Accepts jpg , pjpg (progressive jpeg), png , gif , webp or avif . Defaults to jpg . | fm=webp |
Fit
The fit
parameter sets how the image is fitted to its target dimensions.
The accepted values for fit
are as follows:
Value | Description | Example |
---|---|---|
contain | This is the default. Resizes the image to fit within the width and height boundaries without cropping, distorting or altering the aspect ratio. | fit=contain |
max | Resizes the image to fit within the width and height boundaries without cropping, distorting or altering the aspect ratio, and will also not increase the size of the image if it is smaller than the output size. | fit=max |
fill | Resizes the image to fit within the width and height boundaries without cropping or distorting the image, and the remaining space is filled with the background color. The resulting image will match the constraining dimensions. | fit=fill |
fill-max | Resizes the image to fit within the width and height boundaries without cropping but upscaling the image if it's smaller. The finished image will have remaining space on either width or height (except if the aspect ratio of the new image is the same as the old image). The remaining space will be filled with the background color and the resulting image will match the constraining dimensions. | fit=fill-max |
stretch | Stretches the image to fit the constraining dimensions exactly. The resulting image will fill the dimensions, and will not maintain the aspect ratio of the input image. | fit=stretch |
crop | Resizes the image to fill the width and height boundaries and crops any excess image data. The resulting image will match the width and height constraints without distorting the image. See the crop section for more information. | fit=crop |
Flip & Rotate
Name | Description | Parameter | Accepted values | Example |
---|---|---|---|---|
Flip | Flips the image. | flip | Accepts v , h and both . | flip=v |
Orientation | Rotates the image. | or | Accepts auto , 0 , 90 , 180 or 270 . Default is auto . The auto option uses Exif data to automatically orient images correctly. | or=90 |
Size
Name | Description | Parameter | Accepted values | Example |
---|---|---|---|---|
Width | Sets the width of the image in pixels. | w | Any number. | w=250 |
Height | Sets the height of the image in pixels. | h | Any number. | h=250 |