Cloudinary Blog

Adding Watermarks, Credits, Badges, and Text Overlays to Images

Adding Watermarks, Credits, Badges, and Text Overlays to Images
Adding watermarks to images and videos, a common practice at major news outlets and blogs, ensures that no one can circulate those media without owner authorization and that no one takes undue credit for their creation. Watermarks are also a must for stock-photo sites that offer previews of images and videos for purchase. Embedding the photographer’s name to or crediting a source in photos is a standard routine. 
This post describes how to apply overlays to images with Cloudinary’s image transformation techniques, which are effective text-overlay tools. Besides adding watermarks, you can also edit them by, say, adjusting their opacity or brightness. Additionally, you can embed custom badges and medals to your users’ profile pictures, merge arbitrary text to images on your site, and input other enhancement tweaks.
Sign up for Cloudinary free today!


To add a watermark to an image in a snap: 
1. Upload a semitransparent PNG to your Cloudinary account and assign it an easy-to-remember public ID. This image contains a watermark overlay—the  Cloudinary logo, whose public ID is ‘sample_watermark’:
Sample Watermark
2. Add Cloudinary's overlay transformation parameter ('l' in dynamic URLs). For example, this URL generates a watermarked version of the uploaded image 'brown_sheep.jpg':
Sample Watermark
When retrieving images, consider lazily resizing both the image and its watermark for a perfect fit. Take this JPEG, which has been resized to a 300-px. width with the Cloudinary watermark resized to be 280 px. wide:
Sample Watermark
To downsize the watermark and position it arbitrarily, add the 'gravity', 'x', and 'y' transformation parameters. For example, the following URL adds an 80-px. wide watermark 5 px. from the bottom-right corner of an uploaded image that is resized to fill a 300x200-rectangle based on the face-detection capability:
Here’s the same example in Ruby on Rails:
Copy to clipboard
<%= cl_image_tag("face_center.jpg", 
                 :transformation => {
                   :width => 300, :height => 200, 
                   :gravity => :face, :crop => :fill
                 :overlay => "sample_watermark", 
                 :width => 80, :crop => :scale, 
                 :gravity => :south_east, :x => 5, :y => 5, 
                 :html_width => 300, :html_height => 200) %>
In the examples above, Cloudinary adds the watermark to the transformed versions of the uploaded image only; the original, watermarkless image remains accessible through the original URL. To circumvent that, add the watermark to the original image on upload with the ‘transformation’ parameter of Cloudinary’s upload API. Here’s a Ruby example:
Copy to clipboard
                            :transformation => {
                              :overlay => "sample_watermark"

Badges and Medals

Many social sites, such as Foursquare and (a cool service that offers advice on social-based purchases), award badges and medals to users for ongoing in-app achievements by overlaying those trophies to the users’ profile pictures with CSS on the HTML page. Such a technique does not work in emails, however, because of lack of support from modern web-based email clients.
The solution? Dynamically create profile images with embedded badges, again with Cloudinary’s overlay-transformation parameter.
For example, the dynamic URL below generates an image from the Facebook profile-picture of's Mark Shteiman with a badge that depicts him as a member of the founding team.
Here’s the process: The URL request directs Cloudinary to access Facebook’s API, download the latest profile-picture that matches the dimensions as specified, create a face-thumbnail crop with the face-detection technique, round the corners for a nicer look, add a badge icon, and deliver the final version through a fast content delivery network (CDN) with smart caching. Isn't that just amazing? 

Text Overlays

To overlay text on an image, add the related parameters to the dynamic URL. The uploaded image below is labeled with Sea Shell as a text overlay in 60-px. Arial font and positioned 20 px. from the top.
sea shell
For details, see this Cloudinary post.
Alternatively, overlay text with our API. The following Ruby code generates an image labeled Sample Name:
Copy to clipboard
Cloudinary::Uploader.text("Sample Name",
                          :public_id => "dark_name",
                          :font_family => "Arial", :font_size => 12,
                          :font_color => 'black', :opacity => 90)
You can specify font, color, and style parameters to customize the text. For details, see the [related documentation].
The generated image then becomes available through this CDN URL:
Note: If you do not specify a public ID for an image, Cloudinary assigns the latter a unique identifier, persistently mapping the ID to the text and style settings. That way, Cloudinary generates only one version of an image for the same text and style.
Recall that the `I` parameter in URLs overlays  text overlays on images. The following example embeds the text ‘dark_name’ 5 px. from the bottom-right corner of the image:
 Text and Watermark
Here’s the code in Rails:
Copy to clipboard
cl_image_tag("face_center.jpg", :overlay => "text:dark_name", 
             :gravity => :south_east, :x => 5, :y => 5)
Furthermore, you can apply multiple transformations and add overlays by editing the same URL. For example:
A reminder: to overlay text on the original version of an uploaded image, add the text as part of the image’s incoming transformation. See the section on watermarks above for an example.
The many overlay-related features from Cloudinary open exciting horizons for web development. Do capitalize on them and share with us your ideas.

Recent Blog Posts

On-Demand Viewing of Live Video Presents New Opportunities

In early 2020, Cloudinary was planning its fourth annual ImageCon conference, a two-day event in the heart of San Francisco, where we’d congregate with curious digital-media minds to brainstorm best practices for media management. Instead, the COVID-19 pandemic forced the entirety of ImageCon 2020 online. As with all other events being planned, we had to overhaul the content to be communicated on video. Gratifyingly, we found the right partner—the event platform Bizzabo—to turn that into a reality.

Read more
Why the Future of E-commerce Is Live

In a previous post, I discussed how “going live” is gaining popularity across industries and verticals. What began as a way for gamers to jam together has evolved into a medium for broader entertainment and business purposes. To continue the conversation, this post unpacks the current trends of shoppable live streams to shine a light on how brands are leveraging “lives” to connect with shoppers in new ways.

Read more
An Overview of Live-Streaming Video Trends

“Let’s go live.” For decades, that’s what newscasters say as they cut to real-time footage of a colleague reporting in the field. The live-video feed adds visual interest and perspective to a story beyond what can be communicated by someone sitting behind the news desk. In the same way, live-streaming video nowadays adds context to other consumer environments. From gaming and events to shopping and social media, “going live” enhances everyday experiences, and it’s something anyone can do with relative ease.

Read more
Readying Live Streams for Video on Demand

When planning a live broadcast or stream, companies often overlook the redistribution phase, but live-stream videos are useful well beyond their initial streaming. Why? Because not everyone watches the first run. For a wider audience, it makes sense to repost live content on your website under an “events” tab, on YouTube, and other social sites for video on demand (VOD). However, preparing footage for reposting can be a lot of work.

Read more