Effects and enhancements

Image effects and enhancements are a great way to programmatically alter the way images appear on your website or in the app.

This can range from the most basic of edits, such as adjusting brightness or contrast and adding photo filters, to more advanced techniques, including blurring detected faces and correcting CMYK inconsistencies by converting images to sRGB.

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
/brightness/from -100 to 1000
/exposure/from -500 to 5000
/gamma/from 0 to 1000100
/contrast/from -100 to 5000
/saturation/from -100 to 5000
/vibrance/from -100 to 5000
/warmth/from -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.

Reduced brightness
-/brightness/-20/
Original image

Original image

Increased brightness
-/brightness/20/
Reduced exposure
-/exposure/-100/
Original image

Original image

Increased exposure
-/exposure/80/
Reduced gamma
-/gamma/150/
Original image

Original image

Increased gamma
-/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.
Reduced contrast
-/contrast/-25/
Original image

Original image

Increased contrast
-/contrast/25/
Reduced saturation
-/saturation/-25/
Original image

Original image

Increased contrast
-/saturation/25/
Reduced vibrance
-/vibrance/-50/
Original image

Original image

Increased vibrance
-/vibrance/50/

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

Reduced warmth
-/warmth/-50/
Original image

Original image

Increased warmth
-/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

Original image

Reduced saturation, increased contrast, and warmth

Old photo effect
-/saturation/-80/
-/contrast/80/
-/warmth/50/

Increased exposure, saturation, and reduced warmth

Fresh view
-/exposure/50/
-/saturation/50/
-/warmth/-30/

Enhance colors

-/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

Original image 24Kb

Enhanced image

-/enhance/50/ 28Kb

Max enhanced image

-/enhance/100/ 32Kb

Grayscale

-/grayscale/

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

Original image

Original image

Black and white image
-/grayscale/

Invert

-/invert/

Inverts images rendering a ‘negative’ of the input.

Original image

Original image

Inverse image
-/invert/

Photo filters

-/filter/:name/
-/filter/:name/: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.
Filtered image
-/filter/vevera/-100/
Original image

Original image

Filtered image
-/filter/vevera/100/
Filtered image
-/filter/vevera/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:

Filtered image
-/filter/adaris/
Filtered image
-/filter/briaril/
Filtered image
-/filter/calarel/
Filtered image
-/filter/carris/
Filtered image
-/filter/cynarel/
Filtered image
-/filter/cyren/
Filtered image
-/filter/elmet/
Filtered image
-/filter/elonni/
Filtered image
-/filter/enzana/
Filtered image
-/filter/erydark/
Filtered image
-/filter/fenralan/
Filtered image
-/filter/ferand/
Filtered image
-/filter/galen/
Filtered image
-/filter/gavin/
Filtered image
-/filter/gethriel/
Filtered image
-/filter/iorill/
Filtered image
-/filter/iothari/
Filtered image
-/filter/iselva/
Filtered image
-/filter/jadis/
Filtered image
-/filter/lavra/
Filtered image
-/filter/misiara/
Filtered image
-/filter/namala/
Filtered image
-/filter/nerion/
Filtered image
-/filter/nethari/
Filtered image
-/filter/pamaya/
Filtered image
-/filter/sarnar/
Filtered image
-/filter/sedis/
Filtered image
-/filter/sewen/
Filtered image
-/filter/sorahel/
Filtered image
-/filter/sorlen/
Filtered image
-/filter/tarian/
Filtered image
-/filter/thellassan/
Filtered image
-/filter/varriel/
Filtered image
-/filter/varven/
Filtered image
-/filter/vevera/
Filtered image
-/filter/virkas/
Filtered image
-/filter/yedis/
Filtered image
-/filter/yllara/
Filtered image
-/filter/zatvel/
Filtered image
-/filter/zevcen/

Blur

-/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

Original image 17Kb

Blurred image

-/blur/20/ 10Kb

Max image blur

-/blur/100/ 6Kb

Blur region

-/blur_region/:two_dimensions/:two_coords/ -/blur_region/:two_dimensions/:two_coords/:strength/

Blurs the specified region of the image 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 determined automatically based on the size of the region. Note, larger :strength values do not affect the operation performance.

Original image

Original image

Blurred image region at coordinates
-/blur_region/130x180/220,25/
Smart object blur on an image
-/blur_region/30%x80%/50%,10%/20/

Blur faces

-/blur_region/faces/
-/blur_region/faces/:strength/

When faces is specified the regions are selected automatically by utilizing face detection.

Original image (face)

Original image

Face image blur

-/blur-region/faces/
default strength

Max face image blur
-/blur-region/faces/250/
stength 250

You can “bake in” the applied changes and create a new file that can no longer be reverted to its original state.

Unsharp masking

-/blur/:strength/:amount/

There is no specific operation for unsharp masking. Instead, you can adjust the :amount of the blur applied. :amount can be set in the range from –200 to 100 and defaults to 100.

Where the :amount of:

  • 100 stands for the opaque blur image.
  • 0 stands for no changes in the image, the output is equal to the original.
  • Any negative number would mean subtracting the difference between the blurred and original images from the original. That is the unsharp masking behavior.

You can implement unsharp masking with a large blur :strength (100;300) and a small negative :amount (–50;–10) to increase local contrast. Fine-tuned local contrast gives a “pop” to an image and mimics the look created by camera lenses. Local contrast enhancements let you minimize the effects of haze, lens flare, and “dull look.”

When implemented with a small :strength, unsharp masking increases image sharpness. For instance, the /blur/10/-200/ transformation is the full equivalent of /sharp/20/ with the exception that sharp operates much faster.

You can combine unsharp masking with the sharp operation to increase both local contrast and sharpness.

Original image

Original image16Kb

Unsharp masking (reduce blur)

-/blur/100/-50/ 19Kb

Unsharp masking (reduce blur)

-/blur/100/-120/ 22Kb

Sharpen

-/sharp/20/ 20Kb

Reduce blur

-/blur/10/-200/ 20Kb

Sharp and blur

-/sharp/10/-/blur/90/-50/ 21Kb

Sharpen

-/sharp/
-/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

Downscaled image. 15Kb

Sharpen

-/sharp/10/ 17Kb

Max sharpen

-/sharp/20/ 19Kb

Color models and ICC profiles

Uploadcare has image processing operations that provide color profile management and configure Uploadcare’s CDN behavior depending on the size of ICC profiles embedded in images.

Digital images can be stored in different color models depending on how we use them: whether it is displaying, printing, or something else. The most common model for images intended for viewing is RGB, while CMYK is widely used for printing.

While CMYK images are common, some browsers support them poorly. But more importantly, CMYK support is inconsistent across different browsers. This means that if you happen to serve CMYK images on your site, the colors will vary.

To eliminate the inconsistency, by default, we convert all CMYK images to sRGB. Another drawback of rendering CMYK images on a page is the large size of CMYK ICC profiles (those weight more than a regular 1920x1080 JPEG image). This negatively affects your page performance metrics such as First Meaningful Paint (FMP) and Time to Interactive (TTI).

sRGB converted image

-/srgb/fast/, 33Kb
CMYK image converted to sRGB.

sRGB converted image using ICC profile

-/srgb/icc/, 33Kb
CMYK image converted to sRGB using ICC profile.

sRGB converted image that includes original ICC profile (increased size)

-/srgb/keep_profile/, 617Kb
CMYK image with the original ICC profile. Colors depend on a browser.

In turn, an ICC profile defines how we interpret colors for the given color model. ICC profiles are binary files, which can be either embedded in an image or distributed as is.

With RGB images, embedding a profile is optional. If there is no embed, sRGB is assumed as default color space. Since most of the images on the internet are in sRGB, they commonly don’t include any profile embeds. For CMYK images, an embedded ICC profile is mandatory, while still can be absent. In the last case, we assume that the image is in the “Web Coated (SWOP) v2” color space.

Conversion to sRGB

-/srgb/fast/
-/srgb/icc/
-/srgb/keep_profile/

The operation sets how Uploadcare behaves depending on different color profiles of uploaded images. See the table below to learn more about the possible outcomes. We also provide an option to omit the conversion for the cases where you explicitly want CMYK outputs.

The operation defaults to the fast value. However, we plan to optimize our image processing infrastructure to make icc faster and make it default. Both operations ensure consistently displaying images across different browsers.

Depending on the input color model, the parameter you include in the operation, and threshold you set with max_icc_size, one of the four possible outcomes will occur: profile embedding, profile discarding, color conversion, and fast color conversion.

Input Imagefasticckeep_profile
RGB, small profileembeddingembeddingembedding
RGB, large profilediscardingconversionembedding
CMYK imagefast conversionconversionembedding*

“small profile” and “large profile” stand for profile sizes below and above the max_icc_size setting respectively.

Here is the definition for every possible outcome:

  • Profile embedding: no changes in image model or colors. ICC profile, if present in the source image, stays embedded.
  • Profile discarding: no changes in image model or colors. ICC profile, if present, gets stripped off an image.
  • Color conversion: an image will be converted to sRGB using a full-featured color management system.
  • Fast color conversion is performed using a simple formula which doesn’t consider any color profile and thus provides a result different from a color-managed version.

* While we try to preserve the color model and profile for CMYK images with the -/srgb/keep_profile/ setting, this is not always possible. Certain image processing operations require RGB color model, and thus we automatically convert the subjected images to sRGB using the icc mode. The list of operations incompatible with CMYK includes: setfill, overlay, enhance, filter, and Color Adjustments.

ICC profile size threshold

-/max_icc_size/0/
-/max_icc_size/:number/

The operation defines which RGB color profile sizes will be considered “small” and “large” when using srgb in fast or icc modes. The :number stands for the ICC profile size in kilobytes.

The default value is 10 (10240 bytes). Most of the common RGB profile sizes (sRGB, Display P3, ProPhoto, Adobe RGB, Apple RGB) are below the threshold.

Display P3 color profile image

Image with the original
Display P3 color profile. 25Kb.

No profile

-/max_icc_size/0/-/srgb/fast/
No ICC profile, small color shift. 24.5Kb.

Color recognition

Uploadcare provides a solution for analyzing the dominant colors of an image, which can be used, for example, to adjust the background when embedding images on a website.

-/main_colors/:number_of_colors/

The main_colors operation is useful for analyzing dominant colors of an image, matching colors between images, building image-based palettes or doing something fancy with your site or app coloring scheme:

  • :number_of_colors — a number of prevailing colors you’d like to extract from an image: a smaller palette is derived, consisting of colors that are a fine match when representing your input.
    :number_of_colors may be omitted, the default value of 4 is used in the case.

Note: The main_colors operation should come last in your image URL.

main_colors returns a JSON containing an array of 8-bit RGB values specific to the found dominant colors.

Example image
https://ucarecdn.com/153d750a-049f-44dc-8372-853f49320bad/-/preview/-/main_colors/
/:uuid/-/preview/-/main_colors/

For this input image, the operation with no specified parameters will return this JSON:

1{
2 "width": 2000,
3 "main_colors": [
4 [138, 142, 143],
5 [85, 74, 65],
6 [193, 211, 224],
7 [49, 42, 36]
8 ],
9 "height": 2000,
10 "id": "/153d750a-049f-44dc-8372-853f49320bad/-/preview/",
11 "original": {
12 "width": 2000,
13 "geo_location": null,
14 "orientation": null,
15 "datetime_original": null,
16 "format": "JPEG",
17 "id": "153d750a-049f-44dc-8372-853f49320bad",
18 "height": 2000
19 }
20}

The main_colors algorithm involves random number generation, which may lead to slightly different results when applied to a single image repeatedly.

Technically, the operation is an optimized variation of the Local K-means color image quantization algorithm. The algorithm is adapted to a wide variety of input image data and provides results intuitive in terms of human perception.