• ADS
• CSS
• EXCEL
• IMAGE-SERVER
• SCRIPTS
• SEO
• WEB-PAGE-LANGUAGES
• WEB-SERVER
• WEBSITE-MONITORING-AND-BACKUP
IMAGE-SERVER |
CLOUDINARY |
IMAGE-TRANSFORMATION
Image transformation on the fly
The default Cloudinary asset delivery URL has the following structure:
https://res.cloudinary.com/<cloud_name>/<asset_type>/<delivery_type>/<transformations>/<version>/<public_id>.<extension>
Where:
- cloud_name: The name of your Cloudinary account, a unique public identifier for URL building and API access.
- asset_type: The type of asset to deliver. Valid values: image, video, or raw.
- delivery_type: The storage or delivery type. Valid values: upload (the default delivery type for uploaded assets. In most cases, this delivery type indicates that the asset is publicly available), fetch (enables transforming and delivering remote images on the fly)
- transformations: [optional] One or more comma-separated transformation parameters in a single URL component, or a set of chained transformations (separated by slashes). The derived file is also cached on the CDN and is immediately available to all subsequent users requesting the same asset.
- version [Optional] You can include the version in your delivery URL to bypass the cached version on the CDN and force delivery of the latest asset (in the case that an asset has been overwritten with a newer file).
- public_id: The unique identifier of the asset, including the folder structure if relevant.
- extension [Optional] The file extension of the requested delivery format for the asset.
E.g.:
Convert image to grayscale / black white
Convert images to grayscale or black-&-white by setting the effect parameter to grayscale or blackwhite (e_grayscale / e_blackwhite in URLs).
https://res.cloudinary.com/onlinerechargedeal/image/upload/e_grayscale/v1652542163/2022/test002.jpg
https://res.cloudinary.com/onlinerechargedeal/image/upload/e_blackwhite/v1652542163/2022/test002.jpg
https://res.cloudinary.com/onlinerechargedeal/image/upload/e_blackwhite/v1652671927/cloudinary.png
Resize dimensions
- Using an integer value for w (width) or h (height) sets the new dimension to that number in pixels. For example, w_400 sets the width to exactly 400 pixels.
- Using a decimal value for width or height sets the new dimension relative to the original dimension. For example, w_0.5 = 0.5×100 = 50% of the original width.
- Using ih or iw as values sets the dimension to the initial height or initial width of the original image respectively. For example, w_iw sets the width to the same value as the original width of the image.
- Aspect ratio: a:b where a signifies the relative width and b the relative height (e.g., ar_4:3 or ar_16:9).
- Aspect ratio: a decimal value representing the ratio of the width divied by height (e.g., ar_1.33 or ar_2.5 or ar_1.0 which is perfect square)
E.g.
https://res.cloudinary.com/onlinerechargedeal/image/upload/w_400/v1652542163/2022/test002.jpg (image resized to width 400 pixel & aspect ratio preserved)
https://res.cloudinary.com/onlinerechargedeal/image/upload/h_400/v1652542163/2022/test002.jpg (image resized to height 400 pixel & aspect ratio preserved)
https://res.cloudinary.com/onlinerechargedeal/image/upload/w_0.5/v1652595774/2022/actor.png (image resized to width =
0.5 times of original width & aspect ratio preserved)
Resize & Crop
When changing the dimensions of an uploaded image by setting the image's height/width, you need to decide how to resize or crop the image to fit into the requested size. It is denoted by c_. Following values are supported.
- fill: Resizes the image to fill the specified dimensions without distortion i.e. preserving aspect ratio. The image may be cropped as a result.
- crop: Extracts a region of the specified dimensions from the original image without resizing it.
- scale: Resizes the image to the specified dimensions may not retaining the original aspect ratio, so that image not cropped.
- fit: Resizes the image to fit inside the bounding box specified by the dimensions, maintaining the aspect ratio.
- pad: Resizes the image to fit inside the bounding box specified by the dimensions, maintaining the aspect ratio, and applies padding if the resized image does not fill the whole area.
- thumb: Use the thumb mode with automatic gravity (g_auto) to apply more aggressive cropping than the fill mode. This mode attempts to further zoom in and crop out less interesting image regions when relevant in order to include the most interesting objects in the resulting derived image.
E.g.
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_fill,w_400/v1652596410/2022/flower.jpg (image resized & aspect ratio always preserved as
c_fill. Also image not cropped as height not mentioned)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_scale,w_400/v1652596410/2022/flower.jpg (image resized with same aspect ratio as height not mentioned,
c_scale)
https://res.cloudinary.com/onlinerechargedeal/image/upload/w_400,h_350,c_fill/v1652542163/2022/test002.jpg (image cropped, but resized)
https://res.cloudinary.com/onlinerechargedeal/image/upload/w_400,h_350,c_crop/v1652542163/2022/test002.jpg (image cropped without resize)
https://res.cloudinary.com/onlinerechargedeal/image/upload/w_400,h_350,c_scale/v1652542163/2022/test002.jpg (image never cropped, but aspect ratio changed)
https://res.cloudinary.com/onlinerechargedeal/image/upload/w_300,c_fit/v1652542163/2022/test002.jpg (image perfectly resized to fit within given dimension)
https://res.cloudinary.com/onlinerechargedeal/image/upload/w_300,h_300,c_pad/v1652542163/2022/test002.jpg (image perfectly resized to fit given dimension & remaining area is filled with white background)
https://res.cloudinary.com/onlinerechargedeal/image/upload/ar_2.5,w_500,c_fill/v1652595873/2022/nature1.jpg (image resized &
cropped to be placed within width 500 pixel & height = 500/2.5 = 250 pixel; aspect ratio preserved as
c_fill;)
https://res.cloudinary.com/onlinerechargedeal/image/upload/ar_2.0,w_500,c_fill,g_south/v1652595873/2022/nature1.jpg (same as above, but focused to southern portion of main image as
g_south)
Gravity positions for crops
When used with cropping modes that crop out part of an image, the gravity qualifier (g_) specifies which part of the original image to keep when one or both of the requested dimensions is smaller than the original. Values are:
- The basic gravity value is specified by giving a compass direction to include: north_east, north, north_west, west, south_west, south, south_east, east, or center (the default value). E.g., north_east represents the top right corner.
- g_face to automatically detect the largest face in an image and make it the focus of the crop.
- g_faces to automatically detect all faces in an image and make it the focus of the crop.
- g_auto: automatically focusing on the most interesting region of the original image that fits within the required dimensions.
E.g.,
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_fill,g_north,w_550,h_300/v1652595873/2022/nature1.jpg (
c_fill resized the image to fit within given dimension by preserving aspect ratio, so outer portion of main image is cropped.
g_north directs to focus on top portion of main image)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_fill,g_south,w_550,h_300/v1652595873/2022/nature1.jpg (
g_south directs to focus on bottom portion of main image)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_crop,g_face/v1652608375/2022/woman.jpg (crop the face)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_crop,g_faces,h_150,w_150/r_max/v1652676480/2022/couple.jpg (
c_crop parameter crops both faces
g_faces (
g_face = single face);
r_<value> makes rounded corner (value:0-100),
r_max creates rounded corder with maximum value)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_crop,g_faces/v1652677355/2022/rollercoaster.jpg (detect all faces & crop it)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_crop,g_auto,h_200,w_200/v1652613388/2022/fat_cat.jpg (automatically focusing on the most interesting region of the original image that fits within the required dimensions)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_fill,g_auto,h_300,w_300/v1652608375/2022/woman.jpg (auto detects important part of the image)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_thumb,g_auto,h_300,w_300/v1652608375/2022/woman.jpg (
c_thumb with
g_auto: more aggressive cropping than the fill mode. Further zoom in and crop out less interesting image regions)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_crop,g_face/c_fill,w_400/v1652595774/2022/actor.png (chained transformation, seperated by slash)
flag (fl)
Alters the regular behavior of another transformation or the overall delivery behavior. You can set multiple flags by separating the individual flags with a dot (.).
Placement Qualifiers:
- To determine the position of the new layer, you can add the gravity parameter to define the location to place the layer within the base image ('center' by default). The gravity parameter is added in the same component as the layer_apply flag.
fl_layer_apply,g_<compass direction>
- To fine tune the exact location of the layer, you can offset the overlay from the focus of gravity by also adding the x and y coordinate offset parameters. These parameters accept either integer values representing the number of pixels to adjust the overlay position in the horizontal or vertical directions, or decimal values representing a percentage-based offset relative to the containing image (e.g., 0.2 for an offset of 20%).
fl_layer_apply,g_<compass direction>,x_<value>,y_<value>
Add Image on Image (Image overlays)
We can add image (called, overlay image) on another image (called, base image), similar as before. Default overlay type is an image. Else we've to mention the type, e.g., l_text
l_<public id of overlay>/fl_layer_apply
l_<public_id of layer>/<optional layer transformations>/fl_layer_apply,<optional placement qualifiers (of layers)>
E.g.
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_cloudinary/fl_layer_apply/v1526244803/sample.jpg ( Adding an overlay of the image called
cloudinary to
a base image is (l_cloudinary/fl_layer_apply)
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_2022:cloudinary/fl_layer_apply/v1526244803/sample.jpg
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_cloudinary/fl_layer_apply,g_south_west/v1526244803/sample.jpg (direction of overlay image with gravity parameter)
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_cloudinary/w_150/fl_layer_apply,g_south_west,x_5,y_5/v1526244803/sample.jpg (overlay image is resized & position fine tuned with x, y coordinates)
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_cloudinary/c_scale,w_0.3/o_70,e_brightness:80/fl_layer_apply,g_north_east/v1526244803/sample.jpg (overlay image resized to 0.3×100 = 30% of original overlay image. We add opacity
o_<value> & brightness
e_brightness:<value> to overlay image; value:1-100)
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_happy_smiley/c_scale,w_50/fl_layer_apply,g_faces/v1652676480/2022/couple.jpg (overlay image
happy_smiley is resized & paste on
base image (couple) on their faces, detected by
g_faces)
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_happy_smiley/c_scale,fl_region_relative,w_1.2/fl_layer_apply,g_faces/v1652677355/2022/rollercoaster.jpg (Sometimes we use relative width instead of an absolute width for the overlay. The relative width adjusts the size of the overlay image relative to the size of the detected element. To do this, just add the
fl_region_relative flag to your transformation, and specify the width of the overlay image as a percentage (1.0 = 100%) of the deterted element).
fl_region_relative flag instructs Cloudinary to size your layers relative to the regions detected by the specified gravity type.
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_scale,w_400/l_cloudinary/fl_layer_apply/v1652596410/2022/flower.jpg (overlay image > base image, so overflowed)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_scale,w_400/l_cloudinary/fl_layer_apply,fl_no_overflow/v1652596410/2022/flower.jpg ( If you want to ensure that the overlay image size will never be larger than the base image, you can use the
fl_no_overflow flag in the same component as the fl_layer_apply flag.)
Adding Text on Images (Text overlays)
We can add text on the image using l_text: option. Required paramaters are font_family, font_size, font_weight, font_style, font_decoration, stroke, letter_spacing, line_spacing. All these styling options are added with underscore (_)
- font_family: (required) the name of any universally available font (E.g., Arial, Times, Impact, Verdana, Neucha etc) or any custom font. To use custom font, we've to upload it to Cloudinary Media Library (root directory) as an authenticated asset. (See our previous page that how to upload a file as an authenticated asset).
- font_size: (required) the size of the text in pixels.
- font_weight: the font weight. Possible values: normal (default), bold, thin, light.
- font_style: the font style. Possible values: normal (default), italic.
- font_decoration: the font decoration type. Possible values: normal (default), underline, strikethrough.
- stroke: Whether to include an outline stroke. Set the color and weight of the stroke with the bo_ (border) & co_ (color) parameter. Possible values: none (default), stroke.
- letter_spacing_<value>: the spacing between the letters, in pixels.
- line_spacing_<value>: the spacing between multiple lines, in pixels.
l_text:<text styling options>:<text_to_write>/<optional transformations>/fl_layer_apply,<optional placement qualifiers>
E.g.,
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_text:Arial_40:Flower/fl_layer_apply,g_south/v1652542163/2022/test002.jpg (Add a text overlay stating "Flower" using a 40 pixel Arial font)
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_text:AlexBrush-Regular.ttf_100:flower/fl_layer_apply,g_south,y_30/v1652542163/2022/test002.jpg (We use custom font AlexBrush-Regular.ttf; To use it, we first upload the font to Cloudinary Media Library as an authenticated asset. If your custom font is stored in a folder other than the root folder, specify the path using colons as separators. For example: folder1:folder2:myfont.ttf / Make sure to include the file extension when referencing the public_id of the raw file. The extension must be specified in lower-case letters / Underscores are not supported in custom font names. When uploading the font as a raw file, make sure the public_id does not include an underscore).
https://res.cloudinary.com/onlinerechargedeal/image/upload/bo_2px_solid_black,co_blue,l_text:Arial_40:Flower/fl_layer_apply,g_south/v1652542163/2022/test002.jpg (We add border using
bo_ & text color using
co_)
https://res.cloudinary.com/onlinerechargedeal/image/upload/co_rgb:CC3300,l_text:verdana_90_italic_letter_spacing_10:Cool%20Text/bo_5px_solid_blue/fl_layer_apply,g_south,y_20/v1652542163/2022/test002.jpg (In both case we see that border appears very close to text)
https://res.cloudinary.com/onlinerechargedeal/image/upload/co_rgb:CC3300,l_text:verdana_90_italic_letter_spacing_10:Cool%20Text,fl_text_no_trim/bo_5px_solid_blue/fl_layer_apply,g_south,y_20/v1652542163/2022/test002.jpg (if you add a border around the text, or you are using a gravity for your text layer that might place the text too close to the edge of the layer behind it, you can use the
fl_text_no_trim flag to add a small amount of padding around the the text overlay string)
https://res.cloudinary.com/onlinerechargedeal/image/upload/bo_10px_solid_yellow,co_blue,l_text:Arial_100_stroke:Flower/fl_layer_apply,g_south/v1652542163/2022/test002.jpg (Add
stroke to use border on each character)
https://res.cloudinary.com/onlinerechargedeal/image/upload/bo_10px_solid_yellow,co_blue,l_text:Arial_100_stroke:Flower/fl_layer_apply,g_south_west,x_20,y_20/v1652542163/2022/test002.jpg (x = horizontal distance, y = vertical distance)
https://res.cloudinary.com/onlinerechargedeal/image/upload/co_rgb:CC3300,l_text:verdana_90_italic_letter_spacing_10:Cool%20Text/fl_layer_apply,g_south,y_20/v1652542163/2022/test002.jpg (Text colour
co_ use rgb code)
https://res.cloudinary.com/onlinerechargedeal/image/upload/co_rgb:CC3300,l_text:verdana_50:Cool%0AText/fl_layer_apply,g_south_west,x_10,y_10/v1652542163/2022/test002.jpg (You can manually break lines of text by separating each line of text with the newline character (%0A) % zero A)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_scale,w_500,o_40/c_fit,l_text:Neucha_26_bold:Text%20here%20Text%20here%20Text%20here%20Text%20here%20Text%20here%20Text%20here,w_400/fl_layer_apply,g_south,y_20/v1652595774/2022/actor.png (Automatically wrap your text into multiple lines based on a specified maximum width for the text string. To do this, apply the
c_fit crop mode to the text layer and
specify the width to use for word wrapping)
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_scale,w_500,o_40/c_fit,l_text:Neucha_26_bold:Text%20here%20Text%20here%20Text%20here%20Text%20here%20Text%20here%20Text%20here%20Text%20here%20Text%20here%20Text%20here%20Text%20here%20Text%20here%20Text%20here,w_400,h_100/a_10/fl_layer_apply,g_south,y_20/v1652595774/2022/actor.png (If you do limit the height of your overlay text, any text that does not fit within the space defined is cut and an ellipsis (...) is added to the end of the text string to indicate that the text was truncated. Text can be rotated using angle parameter
a_<value> value:0-360).
https://res.cloudinary.com/onlinerechargedeal/image/upload/c_scale,w_400/co_yellow,l_text:Arial_100:Big%20Flowers/fl_layer_apply,fl_no_overflow/v1652596410/2022/flower.jpg (
fl_no_overflow removes any part of overlay text, that is outside of base image)
Note: We do not use special characters (hash(#), comma(,), slashes(/\), percent(%), question mark(?), karat(^) etc) in the URL. For this, we've to use utf-8 encoded form of the special character and add %25 before it. E.g.
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_text:Arial_40:How%20are%20you%20%253F/fl_layer_apply,g_south/v1652542163/2022/test002.jpg
Multiple Overlays (image & text)
Base Image: https://res.cloudinary.com/onlinerechargedeal/image/upload/v1652596410/2022/flower.jpg
- Overlay image: https://res.cloudinary.com/onlinerechargedeal/image/upload/v1652676480/2022/couple.jpg
cropped to a 150x150 circle that includes only the detected faces.
l_2022:couple/c_crop,g_faces,h_150,w_150/r_max/fl_layer_apply,g_north_east
- Overlay image: https://res.cloudinary.com/onlinerechargedeal/image/upload/v1652671927/cloudinary.png
with a relative width of 80% of the base image (fl_relative) and an opacity of 50% and a brightness of 100. fl_relative specifies percentage-based width & height parameters of overlays (e.g., w_0.5 = 0.5×100 = 50%) are relative to the size of the base image instead of to the original size of the overlaying image itself.l_cloudinary/c_scale,fl_relative,w_0.8/o_50/e_brightness:100/fl_layer_apply
- Overlay text: A text string "Sample" in bold 'Impact' font with a size of 40 pixels, placed at a distance of 20 pixels from the bottom of the base image. Color (co_) white
l_text:impact_40_bold:Sample,co_white/fl_layer_apply,g_south,y_20
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_2022:couple/c_crop,g_faces,h_150,w_150/r_max/fl_layer_apply,g_north_east/l_cloudinary/c_scale,fl_relative,w_0.8/o_50/e_brightness:100/fl_layer_apply/l_text:impact_40_bold:Sample,co_white/fl_layer_apply,g_south,y_20/v1652596410/2022/flower.jpg
Nested Overlays
Layers can be nested within layers. Each layer must have its own layer (start with l_<overlay type> & ends with fl_layer_apply components), and the inner layer must be closed before the outer one, like with any nested programming statement.
https://res.cloudinary.com/onlinerechargedeal/image/upload/l_cloudinary/c_scale,w_150,e_blackwhite/l_cloudinary/c_scale,w_50/fl_layer_apply/fl_layer_apply,g_north_east/v1526244803/sample.jpg