Last active
January 4, 2021 03:44
-
-
Save GroupDocsGists/c22738afc8956064dc9c56f62af14622 to your computer and use it in GitHub Desktop.
Add Text Watermark to Images (JPG , PNG) using C# and Java
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
// Add Text Watermark to JPG using C# | |
using (Watermarker watermarker = new Watermarker("filePath/image.jpg")) | |
{ | |
// Set the Text and Watermark Font | |
Font font = new Font("Arial", 30, FontStyle.Bold | FontStyle.Italic); | |
TextWatermark watermark = new TextWatermark("GroupDocs", font); | |
// Set Watermark Properties | |
watermark.ForegroundColor = Color.Black; | |
watermark.TextAlignment = TextAlignment.Right; | |
watermark.X = 70; | |
watermark.Y = 70; | |
watermark.RotateAngle = -30; | |
watermark.Opacity = 0.4; | |
// watermark.BackgroundColor = Color.Blue; | |
// Add the configured watermark to JPG Image | |
watermarker.Add(watermark); | |
watermarker.Save("filePath/outputImage.jpg"); | |
} |
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
// Add Text Watermark to JPG using Java | |
TextWatermark watermark = new TextWatermark("GroupDocs", new Font("Arial", 30, FontStyle.Bold | FontStyle.Italic)); | |
// Set Watermark properties | |
watermark.setForegroundColor(Color.getRed()); | |
watermark.setTextAlignment(TextAlignment.Right); | |
watermark.setOpacity(0.4); | |
watermark.setX(70); | |
watermark.setY(130); | |
// Add Watermark to the source JPG Image | |
Watermarker watermarker = new Watermarker(Constants.JPG_GD); | |
watermarker.add(watermark); | |
watermarker.save(Constants.JPG_OUT); | |
watermarker.close(); |
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
// Add Text Watermark to PNG using Java | |
TextWatermark watermark = new TextWatermark("GroupDocs", new Font("Arial", 30, FontStyle.Bold | FontStyle.Italic)); | |
// Set Watermark properties | |
watermark.setForegroundColor(Color.getBlack()); | |
watermark.setTextAlignment(TextAlignment.Right); | |
watermark.setRotateAngle(-30); | |
watermark.setOpacity(0.4); | |
watermark.setX(70); | |
watermark.setY(70); | |
// Add Watermark to the source PNG Image | |
Watermarker watermarker = new Watermarker(Constants.PNG_GD); | |
watermarker.add(watermark); | |
watermarker.save(Constants.OUTPUT_PNG_PATH); | |
watermarker.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment