ImageEngine supports URL-based image transformations that allow you to pass directives to ImageEngine in the URL string to instruct it on what to do with an image. In other words, directives override the automated decisions made by ImageEngine.
Directives may be “mixed and matched,” and some work only when others are present. For example, fit methods are dependent on height and/or width directives.
Furthermore, some directives are not compatible with each other. For example, the width and screen percentage commands:
/w_100/pc_100/ instruct ImageEngine to serve the images as 100px wide and 100% of screen/viewport size. In this case, the directive
w_100 will have precedence because it is more specific.
Warning: Some directives should be used with caution. For example: if you explicitly ask for an image to be served as webp, all devices will get webp, even those not supporting it.
There are two ways to make use of directives.
- You can append directives in the query string using the
imgengparameter (if you have a CNAME record pointing to your ImageEngine hostname, this is the only option):
- If you’re specifying the origin in the image URL (
http://jelly.comin the example below), directives can also be included in the path:
The examples above will produce a webp image 300px wide.
Section Values Function
URL Your ImageEngine URL or hostname with a CNAME record pointing to ImageEngine.
URL/Path Path to the image relative to your origin host.
key/value pairs ImageEngine transformations to be applied. Optional.
URL Hostname of your origin server (only available with “origin prefixing”).
Note: If another query string is already used in an object's URL, the ImageEngine directive must be separated by an '&' in the URL.
For instance, this pattern will not work:
Instead, make sure to use an & instead of a second ?:
List of supported directives
Supported directives are listed and explained below.
||Width||Integer||Desired width in pixels of the resized picture. 1 2||
||Auto width with fallback||Integer||ImageEngine will try to automatically detect the best size based on Client Hints. For mobile devices, ImageEngine will detect the optimal width using WURFL device detection. If no reliable size is found, it will fall back to the pixel size specified. 2 3||
||Height||Integer||Desired height in pixels of the resized picture. 1 2||
||Compression||Integer (0-99)||Amount of compression to apply. Values 0 (less compression) to 99 (maximum compression). Note that the value will have a different impact on different file formats and that too much compression will have an impact on visual quality.||
||Desired format of the image. Note that even if the file extension says for example
||Used together with
||When set, ImageEngine will pass through the origin image unmodified.||
||Sharpness||Integer (0-100)||Adjust the sharpness of the image. Values from
||Rotate||Integer||Will rotate the image by provided degrees. Values from -360 to 360.||
||Percentage of screen||1-100 (float)||This field will use WURFL to calculate the screen width and then scale the image accordingly. 2||
||Crop||Integers||The four crop arguments are width, height of the final image, left and top (pixels from the left and top edges of the image). Note that this function does not scale the image to fit inside width and height.||
||Strip EXIF data||
||If set, the browser will download and save the image on the computer||
||Maximum Device Pixel Ratio||1-5 (float)||The maximum DPR that should be considered when resizing and optimizing the image.||
1 If a fit method is not specified, and only width or height is specified, it will select “box”.
2 The target pixel size is actual intrinsic pixels (“CSS pixels”) and does not account for high DPI screens. For example, if you request a 200px wide image for a screen with
DPR: 2, the image will still be 200px wide, not 400px.
3 For mobile devices, where client hints are not available, ImageEngine will by default detect the resolution width of the screen and not the viewport size. For example, if the viewport sizes measured in “CSS pixels” is 360 pixels, the resolution width, used by ImageEngine to determine maximum size of the image, might be 720px if the DPR of the screen is 2 (360px x 2). You can choose not to honor high DPI screens in the settings.
Fit Method Descriptions
box scales the image according to the dimension specified. For instance,
/m_box/h_100/w_100/ will create a box of 100px x 100px and will fit the image inside the box will, retaining the image's aspect ratio.
cropbox will resample the image as small as possible while showing no canvas. This will result in some cropping if the source and output aspect ratios differ.
letterbox is the same as the box, except the returned image is the exact specified size. Bars of black are placed around the image if necessary, but the image will not be scaled up. To use a color other than black, you can specify the HEX color code after the letterbox directive, like this for red:
/m_letterbox_ff0000/. The canvas opacity can also be specified for images that support transparency. This is would be specified as the third parameter of m:
stretch will change the aspect ratio of the image to fill the new canvas defined by
h_*. if the requested values
h_* are higher than the width and hight of the image at the origin, the width and hight of the origin will be the maximum.
outside will resize the image to be as small as possible while ensuring its dimensions are greater than or equal to both width and height. Aspect ratio is preserved. For example, if the requested dimensions of the image is 100x100px. Your original image is 800x400,
outside will reduce the image to 200x100 px since the 100x100 box must fit inside your image.