Add watermarks to images

GroupDocs.Watermark adds watermarks to raster images, including multi-frame formats such as TIFF and GIF. For multi-frame images, open the file with the format-specific load options and target a frame with the matching watermark option.

Add a watermark to a particular frame

Open a TIFF with TiffImageLoadOptions and use TiffImageWatermarkOptions with frame_index to watermark a specific frame.

from groupdocs.watermark import Watermarker
from groupdocs.watermark.watermarks import TextWatermark, Font, Color
from groupdocs.watermark.common import HorizontalAlignment, VerticalAlignment
from groupdocs.watermark.options.image import TiffImageLoadOptions, TiffImageWatermarkOptions

def add_watermark_to_image():
    with Watermarker("./image.tiff", TiffImageLoadOptions()) as watermarker:
        watermark = TextWatermark("CONFIDENTIAL", Font("Arial", 19.0))
        watermark.foreground_color = Color.red
        watermark.horizontal_alignment = HorizontalAlignment.CENTER
        watermark.vertical_alignment = VerticalAlignment.CENTER

        options = TiffImageWatermarkOptions()
        options.frame_index = 0
        watermarker.add(watermark, options)

        watermarker.save("./output.tiff")

if __name__ == "__main__":
    add_watermark_to_image()

image.tiff is the sample file used in this example. Click here to download it.

Binary file (TIFF, 364 KB)

Download full output

For a single-frame image (BMP, PNG, JPEG), open it directly with Watermarker("photo.png") and add the watermark without frame options. To watermark the images embedded inside a document, see Adding watermark to images inside a document.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.