---
title: "Draw text watermark on thumbnail image"
canonical: https://www.graphicsmill.com/samples/LargeImages/Transforms/TextWatermarkOnThumnail_cs
product: "Graphics Mill"
source: "LargeImages/Transforms/TextWatermarkOnThumnail.cs"
---

# Draw text watermark on thumbnail image

This sample shows how to create a thumbnail image and draw a semi-transparent text watermark on top of it using the GraphicsMill transforms and advanced drawing APIs.
It demonstrates how to resize the source image with the [Resize](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_Resize.htm>) transform, register a custom font, and render text with [Drawer](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_AdvancedDrawing_Drawer.htm>) and [PlainText](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_AdvancedDrawing_PlainText.htm>).
You can read more information about drawing in the [documentation](<https://www.graphicsmill.com/docs/gm/advanced-drawing.htm>).

## Instruction

Use the Pipeline API to create a thumbnail from an input image and overlay
a semi-transparent text watermark in the bottom-left corner, using a custom
font and the drawing subsystem.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Drawing;
using Aurigma.GraphicsMill.Transforms;
```

## Code Snippet

```csharp
// Read the source image and prepare pipeline elements.
using (var reader = ImageReader.Create("Venice.jpg"))
using (var resize = new Resize(500, 500, ResizeInterpolationMode.Anisotropic9, ResizeMode.Fit))
using (var drawer = new Drawer())
using (var writer = new JpegWriter("TextWatermark.jpg"))
using (var fr = new CustomFontRegistry())
{
    // Add font to the custom font registry and get its PostScript name.
    var psName = fr.Add("Jost-Regular.ttf")[0].PostscriptName;

    // Configure the Drawer to render the watermark text.
    drawer.Draw += (sender, e) =>
    {
        // Set the custom font registry to the current graphics context.
        e.Graphics.FontRegistry = fr;

        // Create the font to be used for the watermark text.
        var font = e.Graphics.CreateFont(psName, 50);

        // Create the  text object with semi-transparent white brush.
        var text = new PlainText("WATERMARK TEXT", font)
        {
            Brush = new SolidBrush(RgbColor.White.ScaleAlpha(0.7f)),
            Alignment = TextAlignment.Left,
        };

        // Place the text with a small margin from the left/bottom edges.
        var margin = 10;

        text.Position = new System.Drawing.PointF(margin, e.Height - margin);

        // Draw the watermark text onto the image.
        e.Graphics.DrawText(text);
    };

    // Run the pipeline.
    Pipeline.Run(reader + resize + drawer + writer);
}
```

## Explanation

The code:

- Reads the source image "Venice.jpg" using ` ImageReader `.
- Resizes the image to fit within 500x500 pixels while preserving aspect ratio
using the ` Resize ` transform in ` ResizeMode.Fit ` with
` ResizeInterpolationMode.Anisotropic9 `.
- Registers a custom TrueType font (` Jost-Regular.ttf `) in a
` CustomFontRegistry `.
- Uses a ` Drawer ` element with a ` Draw ` event handler to:
- Configure the graphics context to use the custom font registry.
- Create a ` PlainText ` object with the string "WATERMARK TEXT" and
a 50 pt font size.
- Apply a semi-transparent white brush (` RgbColor.White.ScaleAlpha(0.7f) `).
- Position the text with a 10-pixel margin from the left and bottom edges
of the thumbnail.
- Draw the text onto the resized image.
- Runs the pipeline ` reader + resize + drawer + writer ` with
` Pipeline.Run `.
- Saves the resulting watermarked thumbnail as "TextWatermark.jpg" using
` JpegWriter `.

## Tags

- [Pipeline](<https://www.graphicsmill.com/samples/tags/pipeline_md>): Working with images via the Pipeline API
- [Resize](<https://www.graphicsmill.com/samples/tags/resize_md>): Resizing images
- [Text](<https://www.graphicsmill.com/samples/tags/text_md>): Rendering and formatting text
- [Thumbnail](<https://www.graphicsmill.com/samples/tags/thumbnail_md>): Generating thumbnails from images

## Input

- [Venice.jpg](<https://www.graphicsmill.com/samples/LargeImages/compiled/Debug/Venice_jpg>) (preview)

## Output

- [TextWatermark.jpg](<https://www.graphicsmill.com/samples/LargeImages/compiled/Debug/TextWatermark_jpg>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.ImageReader](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_ImageReader.htm.md>)
- [Aurigma.GraphicsMill.Codecs.ImageReader.Create(String)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_ImageReader_Create_1_bb3a7a4f.htm.md>)
- [Aurigma.GraphicsMill.Codecs.JpegWriter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_JpegWriter.htm.md>)
- [Aurigma.GraphicsMill.Color.ScaleAlpha(Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Color_ScaleAlpha_1_7a94462e.htm.md>)
- [Aurigma.GraphicsMill.Drawing.CustomFontRegistry](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_CustomFontRegistry.htm.md>)
- [Aurigma.GraphicsMill.Drawing.CustomFontRegistry.Add(String)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_CustomFontRegistry_Add_1_bb3a7a4f.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Drawer](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Drawer.htm.md>)
- [Aurigma.GraphicsMill.Drawing.DrawEventArgs.Graphics](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_DrawEventArgs_Graphics.htm.md>)
- [Aurigma.GraphicsMill.Drawing.FontAddResult.PostscriptName](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_FontAddResult_PostscriptName.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.CreateFont(String,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_CreateFont_2_1dbfa9fa.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DrawText(Text)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawText_1_f576d03f.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.FontRegistry](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Graphics_FontRegistry.htm.md>)
- [Aurigma.GraphicsMill.Drawing.PlainText](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_PlainText.htm.md>)
- [Aurigma.GraphicsMill.Drawing.PlainText.Alignment](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_PlainText_Alignment.htm.md>)
- [Aurigma.GraphicsMill.Drawing.PlainText.Position](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_PlainText_Position.htm.md>)
- [Aurigma.GraphicsMill.Drawing.SolidBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_SolidBrush.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Text.Brush](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Text_Brush.htm.md>)
- [Aurigma.GraphicsMill.Drawing.TextAlignment](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_TextAlignment.htm.md>)
- [Aurigma.GraphicsMill.Transforms.Resize](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_Resize.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ResizeInterpolationMode](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_ResizeInterpolationMode.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ResizeMode](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_ResizeMode.htm.md>)
