
Do you know those little GIFs that bring some excitement to your chats? Well, we’ve got a cool trick for you. Be ready to put your own words on them! In this blog post, we’ll explain how to do it using C# programming and REST API. It’s easier than you might think, even if you’re not familiar with tech stuff. Get ready to level up your GIF game!
- Step 1: Set Up C# GIF Watermarker SDK
- Step 2: Commence the initialization of the API Client
- Step 3: Upload the Document
- Step 4: Add Overlay Text on a GIF
- Step 5: Download Output file
Step 1: Set Up C# GIF Watermarker SDK
First, ensure that you have the GroupDocs.Watermark Cloud SDK for .NET set up in your project. You can add this SDK to your project through the NuGet package manager, or by utilizing the subsequent command in the .NET CLI:
dotnet add package GroupDocs.Watermark-Cloud --version 23.4.0
Step 2: Commence the Initialization of the API Client
To set up the API client, kindly obtain your Client ID and Client Secret from the dashboard, and then insert the provided code as demonstrated below:
//Get clientId & clientSecret from https://dashboard.groupdocs.cloud (free registration is required). | |
string clientId = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; | |
string clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; | |
string myStorage = "test-internal-storage"; | |
var configuration = new Configuration(clientId, clientSecret); | |
configuration.ApiBaseUrl = "https://api.groupdocs.cloud"; |
Step 3: Uploading the GIF Image
Before applying a watermark to a GIF image, it’s necessary to upload a GIF image where you intend to add the watermark. You can accomplish this by employing any of the subsequent methods to upload the file to cloud storage:
- Upload all files one by one using Upload File API from the browser.
- Using the dashboard.
- Upload programmatically using the code example given below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
// Create necessary API instances var storageApi = new StorageApi(configuration); var fileApi = new FileApi(configuration); var path = @"H:\groupdocs-cloud-data"; var files = Directory.GetFiles(path, "*.gif", SearchOption.AllDirectories); foreach (var file in files) { var relativeFilePath = file.Replace(path, string.Empty).Trim(Path.DirectorySeparatorChar); var response = storageApi.ObjectExists(new ObjectExistsRequest(relativeFilePath, myStorage)); if (response.Exists != null && !response.Exists.Value) { var fileStream = File.Open(file, FileMode.Open); fileApi.UploadFile(new UploadFileRequest(relativeFilePath, fileStream, myStorage)); fileStream.Close(); } }
As a result, the uploaded files will be available in the [files section][https://dashboard.groupdocs.cloud/files] of your dashboard on the cloud.
Step 4: Create Overlay Text on a GIF using C#
Here are the steps and sample code that shows how to add a watermark to a GIF image in C# using GIF watermarking REST API.
- First: Obtain credentials (AppKey and AppSID).
- Next: Configure API and initialize WatermarkApi.
- Next: Specify GIF file path.
- Next: Define watermark options (text, font, size).
- Next: Create request.
- Last: Add the watermark using the API.
The following code example shows how to insert a watermark to a GIF image in C# using GIF watermarking REST API.
string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud | |
string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.groupdocs.cloud | |
var configuration = new Configuration(MyAppSid, MyAppKey); | |
var apiInstance = new WatermarkApi(configuration); | |
var fileInfo = new FileInfo | |
{ | |
FilePath = "sample.gif" | |
}; | |
var options = new WatermarkOptions() | |
{ | |
FileInfo = fileInfo, | |
WatermarkDetails = new List<WatermarkDetails> | |
{ | |
new WatermarkDetails | |
{ | |
TextWatermarkOptions = new TextWatermarkOptions | |
{ | |
Text = "Hello World!", | |
FontFamilyName = "Arial", | |
FontSize = 12d, | |
} | |
} | |
} | |
}; | |
var request = new AddRequest(options); | |
var response = apiInstance.Add(request); |
You’ll see the output in the following screenshot:

Step 5: Download Resultant GIF File
The code given in the previous step saves the resultant file on the cloud. To download it, you can use the following code snippet.
Conclusion
By the end of this blog post, you’ll have a comprehensive understanding of how to integrate overlay text onto GIFs using GroupDocs.Watermark Cloud REST API and its C# SDK. Get ready to elevate your GIFs and captivate your audience with dynamic and engaging visual content.
The GroupDocs.Watermark Cloud SDK for .NET streamlines the process and offers a range of customization choices. You’re encouraged to delve into the documentation and try out diverse configurations to craft watermarks on your images or documents that perfectly match your branding needs.
Moreover, you’ll find an API reference section enabling direct visualization and interaction with our APIs directly from your browser. The comprehensive source code of the C# SDK is openly accessible on Github.
Ultimately, our efforts persist in generating novel blog content centered around distinct file formats and their parsing through REST API. Stay engaged for the latest happenings. Wishing you coding success and satisfaction!
Free Online GIF Watermarker App
For a complimentary way to add overlay text to GIFs, give the online GIF watermarking application a whirl. This GIF watermarking tool is created using the previously mentioned C# watermark library.
Ask a question
In case you would have any queries or confusion about the GIF Watermarker, please feel free to contact us via our forum.
See Also
Here are some related articles that you may find helpful: