Transformations

Adding additional image transformations is simple. There are two ways to add them to your image. Firstly, you can use data-blink-ops. This approach has syntax similar to inline CSS:

<img
  data-blink-ops='filter: nerion; enhance: 15; mirror'
  data-blink-src='https://storage.example.com/logo.png'
/>

Secondly, you can use specific data attributes. Example from the above can be rewritten in the following way and produce the same result:

<img
  data-blink-filter='nerion'
  data-blink-enhance='15'
  data-blink-mirror
  data-blink-src='https://storage.example.com/logo.png'
/>

Adaptive Delivery SDK adds resize, format and quality by default. We don’t recommend changing it, because it calculates parameters based on the device context.

Below is the full list of transformations with the relevant examples.

Image Filtering

Enhance

enhance: :strength

Auto-enhances an image by performing the following operations: auto levels, auto contrast, and saturation sharpening. :strength values should be in the range from 0 to 100. The default value is 50.


Original image. 10.3Kb

enhance: 50 13.5Kb

enhance: 100 17Kb

Sharpen

sharp: :strength

Sharpens an image, might be especially useful with images that were subjected to downscaling. :strength can be in the range from 0 to 20 and defaults to the value of 5.


Downscaled image. 16.1Kb

sharp: 10 21.4Kb

sharp: 20 25Kb

Blur

blur: :strength

Blurs images by the :strength factor. The filtering mode is Gaussian Blur, where :strength parameter sets the blur radius — effect intensity. Technically, :strength controls the Gaussian Blur standard deviation multiplied by ten. The value of :strength might come up to 5000, while the default value is 10. Note, different :strength values do not affect the operation performance.


Original image. 14Kb

blur: 10 7.6Kb

blur: 100 2.4Kb

Color Adjustment

brightness: :value
exposure: :value
gamma: :value
contrast: :value
saturation: :value
vibrance: :value
warmth: :value

Uploadcare features a set of operations for adjusting color properties of an image.

The :value parameter controls the strength of any applied adjustment. Ranges of the :value parameter differ between operations. There also is a zero point for each operation — the value producing outputs equal to original images.

Operation:value rangeZero point
brightnessfrom -100 to 1000
exposurefrom -500 to 5000
gammafrom 0 to 1000100
contrastfrom -100 to 5000
saturationfrom -100 to 5000
vibrancefrom -100 to 5000
warmthfrom -100 to 1000

The first three operations: brightness, exposure, and gamma are very similar. Unlike exposure and gamma, brightness works in a straightforward manner: the :value gets added to each color channel; out-of-range values are cut. Thus, when increasing brightness, brighter image features can be lost. Same works for darker features on brightness decrease. Conversely, exposure and gamma compress color values distribution in either lighter or darker areas depending on the provided :value, thus preserving details.


brightness: -20

Original image.

brightness: 20

exposure: -100

Original image.

exposure: 80

gamma: 150

Original image.

gamma: 70

The next three operations adjust color diversity and dynamic range in images:

  • contrast affects both colors and dynamic range; on increase, images lose both bright and dark details.
  • saturation uniformly bumps up color intensity leaving the dynamic range unchanged.
  • vibrance cleverly increases the intensity of muted colors and leaves the well-saturated ones alone. The operation produces more realistic results when applied to typical photos.

contrast: -25

Original image.

contrast: 25

saturation: -25

Original image.

saturation: 25

vibrance: -50

Original image.

vibrance: 50

Last but not least, the warmth operation adjusts color temperature in images.


warmth: -50

Original image.

warmth: 50

You can combine any adjustments to achieve the needed outputs. Piping the operations won't get you any performance or precision losses since all adjustments are applied in one pass.


Original image.

Old photo effect.
saturation: -80
contrast: 80
warmth: 50

Fresh view.
exposure: 50
saturation: 50
warmth: -30

Filter

filter: :name
filter-amount: :amount

Applies one of predefined photo filters by its :name. The way your images look affects their engagement rates. You apply filters thus providing beautiful images consistent across content pieces you publish.

The :name should be one of the following: adaris, briaril, calarel, carris, cynarel, cyren, elmet, elonni, enzana, erydark, fenralan, ferand, galen, gavin, gethriel, iorill, iothari, iselva, jadis, lavra, misiara, namala, nerion, nethari, pamaya, sarnar, sedis, sewen, sorahel, sorlen, tarian, thellassan, varriel, varven, vevera, virkas, yedis, yllara, zatvel, zevcen.

:amount can be set in the range from -100 to 200 and defaults to 100. The :amount of:

  • 0 stands for no changes in the image, the output is equal to the original.
  • Values in the range from 0 to 100 gradually increase filter strength; 100 makes filters work as designed.
  • Values over 100 emphasizes filter effect: the strength of applied changes.
  • Any negative number would mean subtracting the difference between the filtered and original images from the original. That will produce a "negative filter" effect.

filter: vevera;
filter-amount: -100

Original image.

filter: vevera;
filter-amount: 100

filter: vevera;
filter-amount: 200

All filters provide predictable outputs with the :value ranging from 0 to 100. For some filter presets, setting the :amount value outside those bounds may produce weird results. For example, all filters producing grayscale outputs will result in a negative image when set to the :amount greater than 100. Set to negative values, those will saturate an image.

Here's how all of our filters look like:


filter: adaris

filter: briaril

filter: calarel

filter: carris

filter: cynarel

filter: cyren

filter: elmet

filter: elonni

filter: enzana

filter: erydark

filter: fenralan

filter: ferand

filter: galen

filter: gavin

filter: gethriel

filter: iorill

filter: iothari

filter: iselva

filter: jadis

filter: lavra

filter: misiara

filter: namala

filter: nerion

filter: nethari

filter: pamaya

filter: sarnar

filter: sedis

filter: sewen

filter: sorahel

filter: sorlen

filter: tarian

filter: thellassan

filter: varriel

filter: varven

filter: vevera

filter: virkas

filter: yedis

filter: yllara

filter: zatvel

filter: zevcen

Grayscale

grayscale

Desaturates images. The operation has no additional parameters and simply produces a grayscale image output when applied.


Original image.

grayscale

Invert

invert

Inverts images rendering a 'negative' of the input.


Original image.

invert

Image Rotation

Rotate

rotate: :angle

Right-angle image rotation, counterclockwise. The value of :angle must be a multiple of 90.


Original image.

rotate: 90

rotate: 180

rotate: 270

Flip

flip

Flips images.


Original image.

flip

Mirror

mirror

Mirrors images.


Original image.

mirror

Overlay

The overlay operation allows to layer images one over another.

overlay-uuid: :uuid
overlay-dimensions: :relative_dimensions
overlay-coordinates: :relative_coordinates
overlay-opacity: :opacity

One of the most common use cases here are watermarks: semi-transparent images layered over opaque ones to complicate their unauthorized usage, etc.

  • :uuid — UUID of an image to be layered over input. To be recognized by :uuid, that image should be related to any project of your account.
  • :relative_dimensions — linear dimensions of the overlay image. The aspect ratio of an overlay is preserved. What you set is a maximum linear size along one of the axes: -/overlay/:uuid/50%x50%/ means any linear dimension of the overlay can not exceed 50% in size. Default size setting is 100%.
  • :relative_coordinates — position of the overlay over your input. By default, an overlay is positioned in the top-left corner of an input. Coordinates represent an offset along each of the axes in either pixel or percent format. In general, the coordinate system is similar to the CSS background-position.
  • :opacity — controls the opacity of the overlay in percent format. Your overlay may either be initially semi-transparent or made to be so by tuning :opacity.

Since % is an escape char in URLs, it can’t be used as-is and should be replaced with either %25 escape sequence or the p char, which is a more readable and concise option.

Every overlay parameter is optional and can be omitted. However, the order of parameter URL directives should be preserved.


overlay-uuid: b18b5179-b9f6-4fdc-9920-5539f938fc44;
overlay-dimensions: 50%25x50%25;
overlay-opacity: 20%25

Specifying size and opacity, positioning is omitted.

overlay-uuid: b18b5179-b9f6-4fdc-9920-5539f938fc44;
overlay-dimensions: 50%25x50%25;
overlay-coordinates: center

Specifying size and position, opacity is omitted.

Resizing and Cropping

Preview

preview: :two_dimensions

Reduces an image proportionally for it to fit into the given dimensions in pixels. If dimensions are not specified, we use the default values of 2048x2048 pixels.

Resize

resize: :one_or_two_dimensions

Resizes an image to fit into the specified dimensions. With just a single linear dimension specified, preserves your original aspect ratio and resizes an image along one of its axes.

Crop

crop: :two_dimensions
crop-position: :two_coords

Crops an image using specified dimensions and offsets. If no offset values are passed into the operation, the top-left image corner is used by default.


Original image.

crop: 200x130; crop-position: center

crop: 200x130; crop-position: 200,70

Scale Crop

scale-crop: :two_dimensions
scale-crop-position: :type

When :type is not specified.

Scales down an image until one of its dimensions gets equal to some of the specified ones; the rest is cropped. This proves useful when your want to fit as much of your image as possible into a box. Let us compare the two resizing methods:


resize: 1024x1024
Requested size.
Distorted.

preview: 1024x1024
Adjusted size.
No distortion.

scale-crop: 1024x1024
Requested size.
No distortion.

When :type is set to smart.

Switching the crop type to smart enables the content-aware mechanics: detecting faces and other visually important objects or areas in images. Specifically, with the setting, Uploadcare applies AI-based algorithms implementing deep neural networks to automatically detect visually important areas in images and crop the rest.

Example:


scale-crop: 1024x1024;
scale-crop-position: smart

Smart cropping.

Stretch

stretch: :mode

Sets the resize behavior when a source image is smaller than the resulting dimensions. The following modes can apply:

  • on — stretches an image up, the default option.
  • off — forbids stretching an image along any dimension that exceeds image size along any of its axes.
  • fill — does not stretch an image, the color-filled frame is rendered around instead, the default fill color is used.

preview: 160x160
resize: 220x

preview: 160x160
stretch: off
resize: 220x

preview: 160x160
stretch: fill
resize: 220xsetfill: 8d8578

Compression and Performance

Format

format: :format

Converts an image to one of the following formats:

  • jpeg — JPEG is a lossy image format (good compression, good for photos). JPEG doesn’t support an alpha channel, hence you can use the setfill operation that sets a background color. All browsers support JPEG.
  • png — PNG is a lossless format (good compression only for graphics) with alpha channel support. Supported by all browsers.
  • webp — WebP is a modern image format that supports alpha channel and lossy compression. The format is good for all kinds of images but supported by a limited number of browsers.
  • auto — the image format used for content delivery is set according to the presence of an alpha channel in your input and capabilities of a client.

Technically, the default behavior of auto is about always trying to deliver WebP images based on checking the Accept header. We do it if a client supports the image/webp MIME-type and you are running the default Uploadcare setup with our storage and the default CDN domain, ucarecdn.com.


png 135Kb
Transparent

jpeg 8.8Kb
Opaque

webp 11.5Kb
Transparent, size is equal
to the opaque one.

Quality

quality: :value

Sets the level of image quality that affects file sizes and hence loading speeds and volumes of generated traffic. quality works with JPEG and WebP images.

When your input and output are both JPEGs and no destructive operations are applied, your output image quality is limited to the initial input quality: when you upload a highly compressed image, you can use the normal setting or go even higher, but it will not affect neither your compression settings nor file size.

  • normal — the default setting, suits most cases.
  • better — can be used to render relatively small and detailed previews. ≈125% file size compared to normal.
  • best — useful for hi-res images, when you want to get perfect quality without paying much attention to file sizes. ≈170% file size.
  • lighter — useful when applied to relatively large images to save traffic without significant losses in quality. ≈80% file size.
  • lightest — useful for retina resolutions, when you don’t have to worry about the quality of each pixel. ≈50% file size.

best 32Kb

lighter 18.6Kb

lightest 12.3Kb

Progressive JPEG

progressive: yes
progressive: no

Returns a progressive image. In progressive images, data is compressed in multiple parts of progressively higher detail. This is ideal for large images that will be displayed while downloading over a slow connection allowing a reasonable preview after receiving only a portion of the data. The operation does not affect non-JPEG images; does not force image formats to JPEG.

Questions?

We’re always happy to help with code, integration, and other stuff.
Search our site for more info or post your question in our Community Area.