Add 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 →

One of the main features of GroupDocs.Watermark is adding image watermarks to documents. You can add watermarks to documents or images from a local path, as well as from a stream. For a full list of supported formats, check Supported document formats.

Add an image watermark

To add an image watermark, follow these steps:

  1. Open the document by passing its path (or a stream) to the Watermarker class.
  2. Create an ImageWatermark from the watermark image file (or a stream).
  3. Position the watermark — for example, set horizontal_alignment, vertical_alignment, and opacity.
  4. Call add() to apply the watermark and save() to write the result.
from groupdocs.watermark import Watermarker
from groupdocs.watermark.watermarks import ImageWatermark
from groupdocs.watermark.common import HorizontalAlignment, VerticalAlignment

def add_image_watermark():
    with Watermarker("./sample.docx") as watermarker:
        # Build an image watermark from a logo file and center it
        watermark = ImageWatermark("./logo.png")
        watermark.horizontal_alignment = HorizontalAlignment.CENTER
        watermark.vertical_alignment = VerticalAlignment.CENTER
        watermark.opacity = 0.7

        watermarker.add(watermark)
        watermarker.save("./output.docx")

if __name__ == "__main__":
    add_image_watermark()

sample.docx and logo.png are the sample files used in this example. Download sample.docx and logo.png.

Binary file (DOCX, 127 KB)

Download full output

What’s next

GroupDocs.Watermark offers more capabilities for image watermarks — loading from streams, scaling, tiling, and absolute or relative positioning. See Adding image watermarks in the advanced guide.