Skip to content

Instantly share code, notes, and snippets.

@groupdocs-com-kb
Last active April 24, 2024 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save groupdocs-com-kb/7e5b9f6750c4dcca96e34466255b107e to your computer and use it in GitHub Desktop.
Save groupdocs-com-kb/7e5b9f6750c4dcca96e34466255b107e to your computer and use it in GitHub Desktop.
Add Text Watermark to JPG Using C#. For more information, please follow link: https://kb.groupdocs.com/watermark/net/add-text-watermark-to-jpg-using-csharp/
using GroupDocs.Watermark.Common;
using GroupDocs.Watermark.Watermarks;
using GroupDocs.Watermark;
namespace AddTextWatermarktoJPGUsingCSharp
{
internal class Program
{
static void Main(string[] args)
{
// Set License to avoid the limitations of Watermark library
License lic = new License();
lic.SetLicense(@"GroupDocs.Watermark.lic");
// Specify an absolute or relative path to your JPG
using (Watermarker watermarker = new Watermarker("input.jpg"))
{
// Specify the desired text and font for the watermark
TextWatermark watermark = new TextWatermark("Watermark Text",
new Font("Arial", 60, FontStyle.Bold));
// Specify font color and text opacity, rotation and alignments
watermark.ForegroundColor = Color.DarkGreen;
watermark.Opacity = 0.5;
watermark.HorizontalAlignment = HorizontalAlignment.Center;
watermark.VerticalAlignment = VerticalAlignment.Center;
watermark.RotateAngle = -45;
// Apply the watermark
watermarker.Add(watermark);
// Save the resulting JPG
watermarker.Save("output.jpg");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment