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.
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 | Fresh view |
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 24Kb |
|
|
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/ |
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.
-/filter/vevera/-100/ | Original image | -/filter/vevera/100/ | -/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:
-/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/ |
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 17Kb |
|
|
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 | -/blur_region/130x180/220,25/ | -/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 |
| -/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 image16Kb |
|
|
|
|
|
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. 15Kb |
|
|
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).
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.
“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.
Image with the original |
|
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 of4
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.
/:uuid/-/preview/-/main_colors/
For this input image, the operation with no specified parameters will return this JSON:
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.