Adding image watermarks

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Watermark MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-watermark -- dnx GroupDocs.Watermark.Mcp --yes
Folders, licensing and more →

GroupDocs.Watermark API supports adding the following image file types as image watermark:

  • Bmp;
  • Png;
  • Gif;
  • Jpeg.

Add image watermark from local file

Following code snippet shows how to add ImageWatermark to a document. If the document consists of multiple parts (pages, worksheets, slides, frames etc), the watermark will be added to all of them.

advanced_usage.adding_image_watermarks.AddImageWatermark

// Specify an absolute or relative path to your document. Ex: "C:\\Docs\\presentation.pptx"
Watermarker watermarker = new Watermarker("presentation.pptx");                                           
                                                                                                                   
// Use path to the image as constructor parameter                                                                  
ImageWatermark watermark = new ImageWatermark("watermark.jpg");                                             
                                                                                                                   
// Add watermark to the document                                                                                   
watermarker.add(watermark);                                                                                        
                                                                                                                   
watermarker.save("presentation.pptx");                                                                   
                                                                                                                   
watermark.close();                                                                                                 
watermarker.close();                                                                                             

Add image watermark from stream

You can also use a stream of the image to initialize  ImageWatermark instance as shown in below example.

advanced_usage.adding_image_watermarks.AddImageWatermarkUsingStream

// Specify an absolute or relative path to the watermark image. Ex: "C:\\Docs\\watermark.jpg"
FileInputStream watermarkStream = new FileInputStream("watermark.jpg");                           
                                                                                                         
Watermarker watermarker = new Watermarker("image.png");                                         
                                                                                                         
// Use stream containing an image as constructor parameter                                               
ImageWatermark watermark = new ImageWatermark(watermarkStream);                                          
                                                                                                         
// Add watermark to the document                                                                         
watermarker.add(watermark);                                                                              
                                                                                                         
watermarker.save("image.png");                                                                 
                                                                                                         
watermark.close();                                                                                       
watermarker.dispose();                                                                                   
watermarkStream.close();                                                                                 
Warning
ImageWatermark  class implements Closeable interface. Therefore, it is necessary to call close() method when you are done working with the watermark.

For the advanced use of image watermark properties please check the following article about text watermarks, however, the same techniques will work for image watermarks as well: