Transformations

Learn about the ways to work with ixmage and your images
Sample Photo
Sample photo

Resizing and compromising with Quality

Resizing an image can have various combinations for width and height.
When only the width is requested, the height value will be calculated so that the image's aspect ratio is preserved.
Same when only the height is requested. In this case the width will be calculated so the aspect ratio is not affected.
When both the width and height are requested, the resulting image will comply to the dimensions, and the image will be fitted inside still keeping the aspect ratio. Any excess area will be padded with the background color (bgc) specified, or white when there is no background color specified.

There is also a way to specify transparency for the formats that support it.

width aliases: wid | w
The width of the image to request. If only width is specified, the height will be calculated as to retain the image's aspect ratio.
&width=200Request an image with width of 200; The height will be calculated to preserve aspect ratio.
Request an image with width of 200; The height will be calculated to preserve aspect ratio.
&width=100Request an image with width of 100; The height will be calculated to preserve aspect ratio.
Request an image with width of 100; The height will be calculated to preserve aspect ratio.
height aliases: hei | h
The height of the image to request. If only height is specified, the width will be calculated as to retain the image's aspect ratio.
&height=200Request an image with height of 200; The width will be calculated to preserve aspect ratio.
Request an image with height of 200; The width will be calculated to preserve aspect ratio.
&height=100Request an image with height of 100; The width will be calculated to preserve aspect ratio.
Request an image with height of 100; The width will be calculated to preserve aspect ratio.
bgc aliases:
Specify a background when padding is needed. Will also show below transparency.
&w=300&h=120Using width and height to create some padding area. Notice the white area on the sides of the image. The photo was padded with this area to comply with the dimensions, yet not distort the aspect ratio.
Using width and height to create some padding area. Notice the white area on the sides of the image. The photo was padded with this area to comply with the dimensions, yet not distort the aspect ratio.
&bgc=lime&w=300&h=120Use color lime as image background. The white area is now painted lime.
Use color lime as image background. The white area is now painted lime.
&bgc=indigo&w=200&h=90Indigo background.
Indigo background.
&bgc=_000&w=200&h=90Hex color #000 (black).
Hex color #000 (black).

The background color understands web named colors like lime, black, LightSteelBlue, etc.
Here is some reference: Web Colors

To specify that you want to use a hex value, prepend an _ to the value like &bgc=_00ff00

quality aliases: qlt | q
This value can compromise between quality and performance. In the example below, you can see how reducing the quality also reduces the image's size.
&quality=95&w=300At 95% quality, the resulting filesize is 30.7kb (webp format). For jpg it's 33.7kb
At 95% quality, the resulting filesize is 30.7kb (webp format). For jpg it's 33.7kb
&quality=50&w=300At 50% quality, the resulting filesize is 8.2kb (webp format) For jpg it's 9.8kb
At 50% quality, the resulting filesize is 8.2kb (webp format) For jpg it's 9.8kb
&quality=30&w=300At 30% quality, the resulting filesize is 6.1kb (webp format) For jpg it's 7.1kb
At 30% quality, the resulting filesize is 6.1kb (webp format) For jpg it's 7.1kb

The quality parameter only has effect on the default webp format, and the jpg format. The quality value is defaulted to 90 and can be changed in your account's dashboard. This default value is overriden by using the parameter from the url.

More Resizing Transformations

Working with width and height will always preserve aspect ratio.
To open things up for more flexibility, we can make use of the following transformations:

Extend

Allow an image to extend "outside the viewport" and keep its aspect ratio.

extend aliases:
Allow an image to extend beyond the available dimensions/viewport.
&extend=1&w=300&h=150
Sample Photo
&extend=0&w=300&h=150
Sample Photo

Comparing the samples above, notice how the image grew so that it filled the padding to the sides, and the excess of height went "out of sight" (above and below).

The image without extend, relies on padding on its sides to comply with the requested dimensions.
The image with extend, resizes the image to the requested width, and the requested height makes the resulting image "overflow out of sight".

The missing top and bottom areas overflowed outside the dimensions as the content grew horizontally to cover the width. This only works when both width and height are specified as parameters.

Cover

Allow image distortion (lose aspect ratio) to entirely cover the requested dimensions.

cover aliases:
Allow image distortion to fill the available dimensions/viewport.
&cover=1&w=300&h=120Notice how the image grew to the sides to fill the requested dimensions. It did not grow vertically so the aspect ratio was lost.
Notice how the image grew to the sides to fill the requested dimensions. It did not grow vertically so the aspect ratio was lost.

Allow Enlargement

By default, an image will not grow beyond its original dimensions. Meaning if you have an image with original dimensions of 90x90 and you request it as 120x120, the image will be centered in the area, and padded with 15px of bgc all around.

allowenl aliases:
Allow an image to grow beyond its original dimensions.
&allowenl=0&w=300&h=120&bgc=_abdNatural dimensions for this image are 162x72. It will not grow over that, the requested dimensions are padded with bgc and the image is centered.
Natural dimensions for this image are 162x72. It will not grow over that, the requested dimensions are padded with bgc and the image is centered.
&allowenl=1&w=300&h=120&bgc=_abdTurning on allowenl permits the image to grow. You can still see some padded bgc because aspect ratio is preserved.
Turning on allowenl permits the image to grow. You can still see some padded bgc because aspect ratio is preserved.

Visual Optimizations

Resizing images always comes with visual artifacts. The more the dimension changes, the more evident these may manifest. Usually shrinking or enlarging an image will make it fussy.

Here are some actions that help with visual appearance.

sharp aliases:
Sharpening an image after a resize may improve its visual appearance.
&sharp=0
Sample Photo
&sharp=1
Sample Photo

Formats

There are many image formats around on the web.
webp is a recent format that is gaining popularity and compatibility. ixmage uses webp as the default response type because of its benefits in compression, but it will fall-back to png when the requesting client does not mention support for webp (through its accept header).

Even if the source image is a jpg, the response will be of type webp (with jpg fallback when needed) unless explicitly requested as jpg through the format parameter.

format aliases: fmt | f
Request a specific image format. Supported formats: webp, png, jpg, gif
&format=webpwebp Request (4.3kb)
Sample Photo
&format=pngpng Request (24.6kb)
Sample Photo
&format=jpgjpg Request (4.7kb)
Sample Photo
&format=gifgif Request (11.0kb)
Sample Photo

More Transformations

Here are other ways of transforming your image through the querystring.

dpr (Device Pixel Ratio) aliases:
The device pixel ratio helps in presenting the best quality on devices that can handle it. Simply put, it will adjust the width and height values to account for the device DPR. Accepted values range: 1.0 - 5.0
&dpr=1&w=120&h=90Default
Default
&dpr=1.5&w=120&h=90Ratio of 1.5. The dpr made the resulting dimensions 180x135
Ratio of 1.5. The dpr made the resulting dimensions 180x135
&dpr=2&w=120&h=90Ratio of 2. The dpr made the resulting dimensions 240x180
Ratio of 2. The dpr made the resulting dimensions 240x180

dpr should be used along with img attributes of width and height so the multiplication of image dimensions is handled appropriately in the browser.

The "advanced" usage to display a 200x100 image on a device with a dpr of 3, would be to request the image like
?width=200&height=100&dpr=3
and combine this with image properties
<img width="200" height="100" src="ixmage-url">
This will produce an image of dimensions 600x300 which the device browser will then resize to 200x100 so it renders according to the planned layout. From there, the device will work its capabilities to display a much clearer visual.

crop aliases:
Crop an area of an image. Put the area into view. Takes 4 arguments separated by commas: x-offset, y-offset, width, height. x-offset moves the corner point to the left, y-offset moves it down. And width and height make an area/rectangle from that point.
&crop=850,330,300,360&w=320&h=180Select the area, then resize it.
Select the area, then resize it.
&crop=140,220,270,80&w=180&h=260Select the area, then resize it. White padding of 20px is used to honor the w and h params.
Select the area, then resize it. White padding of 20px is used to honor the w and h params.
flip - flop aliases:
Vertical and Horizontal mirror reflections of the image.
&flip=1Vertical mirror projection
Sample Photo
&flop=1Horizontal mirror
Sample Photo
&flip=1&flop=1flip-flop combo
Sample Photo
blur aliases:
Blur the image. Acceptable values range from 1 to 40
&blur=1
Sample Photo
&blur=2
Sample Photo
&blur=3
Sample Photo
pixelate aliases:
Pixelate an image, as an optional blur. Acceptable values: 1, 2, 3, 4
&pixelate=1
Sample Photo
&pixelate=2
Sample Photo
&pixelate=3
Sample Photo

Color Manipulations

The following transformations change the image's colors.

brightness aliases: bright | mod
Change the brightness of the image. Acceptable range between -100 and 100
&brightness=-50&w=180
Sample Photo
&brightness=0&w=180
Sample Photo
&brightness=50&w=180
Sample Photo
saturation aliases: sat
Change the saturation of the image. Acceptable range between -100 and 100
&saturation=-50&w=180
Sample Photo
&saturation=0&w=180
Sample Photo
&saturation=50&w=180
Sample Photo
hue aliases:
Change the hue of the image. Acceptable range between -100 and 100
&hue=-50&w=180
Sample Photo
&hue=0&w=180
Sample Photo
&hue=50&w=180
Sample Photo
sepia aliases:
Give a sepia filter to the image. Acceptable values range 60-100
&sepia=66
Sample Photo
&sepia=77
Sample Photo
&sepia=88
Sample Photo
grey aliases: grayscale | greyscale | gray
Turn image to grayscale
&grey=1
Sample Photo

Templates

When you identify a transformation pattern that you are using in multiple places, it may be a sign that a template can come into play.
A template is used to give a name to a set of transformations.

A template consists of a set of operations that is saved by giving it a name which can be used in the url. The template name will then resolve to the set of operations.

For instance, common transformations that come in handy for an e-commerce website are: small, medium, and large. A small variant of your product image for a listing page, a medium variant to show a preview or initial detail, and a large variant for when the user decides to "zoom-in" for better appreciation.

You can setup these three templates in your alias and give each the appropriate width, height, and quality.

Now on your website markup, instead of requesting an image with /v2/token/alias/image.png?width=90&height=90&quality=60 you can instead do /v2/token/alias/image.png?template=small

Go to detailed example.

Let's define template thumb as &width=90&height=90&quality=50&grey=1

Now on your website markup, you can start using &template=thumb. Now imagine you use this template in various pages on your website, and later decide that you want to remove the grayscale transformation. You can remove it from the template and now the images will start reflecting the change. You complete the change from your control panel instead of possibly multiple references in code and markup.

template aliases: tpl | t
Name a set of transformation for ease of usage.
&template=thumb

While you can add more transformations to urls that use templates, specifying a transformation that has been used in the template will not override it.

Continuing with the thumbnail example, this will not change the width:
&t=thumbnail&w=200

ok!