---
title: "Drawing on Images with Pipelines"
canonical: https://www.graphicsmill.com/docs/gm/drawing-on-images-with-pipelines.htm
product: "Graphics Mill"
---

# Drawing on Images with Pipelines
 
To draw on an image within [Pipeline](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Pipeline.htm.md) use the [Drawer](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Drawer.htm.md) class. This class allows you to draw on [Graphics](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Graphics.htm.md). To learn how to draw with **Graphics** in detail, read the [Drawing Text and Graphics](https://www.graphicsmill.com/docs/gm/advanced-drawing.htm.md) section. The **Drawer** class provides the [Draw](https://www.graphicsmill.com/docs/gm/E_Aurigma_GraphicsMill_Drawing_Drawer_Draw.htm.md) event handler where you should implement all the drawing functionality.
 
**Note** 
The fact that pipelines process large images by stripes means that **Draw** event is fired for each stripe. So it is recommended to create all resource-intensive objects in the [BeginDraw](https://www.graphicsmill.com/docs/gm/E_Aurigma_GraphicsMill_Drawing_Drawer_BeginDraw.htm.md) event handler and release them in [EndDraw](https://www.graphicsmill.com/docs/gm/E_Aurigma_GraphicsMill_Drawing_Drawer_EndDraw.htm.md).
 
We will discuss below how to draw geometrics primitives and vector text using **Pipeline**. In addition, you can observe the [Transforming Images with Pipelines](https://www.graphicsmill.com/docs/gm/transforming-images-with-pipelines.htm.md) article to learn to combine images with pipelines.
 
## Drawing Geometric Primitives
  
The snippet below illustrates how to draw a white border around an image. Read the [Graphics: Drawing Images and Geometric Shapes](https://www.graphicsmill.com/docs/gm/graphics.htm.md) article to learn how to utilize drawing operations.
 
```csharp
using (var reader = ImageReader.Create(@"Images\in.jpg"))
using (var drawer = new Drawer())
using (var writer = ImageWriter.Create(@"Images\Output\out.jpg"))
{
    drawer. Draw += delegate(object sender, DrawEventArgs e)
    {
        var pen = new Pen(System.Drawing.Color.White, 20);
        e.Graphics.DrawRectangle(pen, new System.Drawing.Rectangle(10, 10, e.Width - 20, e.Height - 20));
    };
    Pipeline.Run(reader + drawer + writer);
}
```
 
## Drawing Text
  
**Graphics** allows drawing various types of vector text described in the [Drawing Simple Text Objects](https://www.graphicsmill.com/docs/gm/advanced-drawing-text.htm.md) article. The code below extracts a date and time of image creation from EXIF and draws it on an image as [PlainText](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_PlainText.htm.md). To learn about EXIF metadata in detail read in the [EXIF and IPTC Metadata](https://www.graphicsmill.com/docs/gm/exif-and-iptc-metadata.htm.md) topic.
 
```csharp
using (var reader = ImageReader.Create(@"Images\in.jpg"))
{
    if (reader.Exif != null)
    {
        string dateTime = reader.Exif[ExifDictionary.DateTime].ToString();

        using (var drawer = new Drawer())
        using (var writer = ImageWriter.Create(@"Images\Output\out.jpg"))
        {
            drawer.Draw += delegate(object sender, DrawEventArgs e)
            {
                var text = new PlainText(dateTime, e.Graphics.CreateFont("Courier New", e.Height / 20), new SolidBrush(RgbColor.Red), 
                    new System.Drawing.PointF(450, 150), TextAlignment.Right);
                e.Graphics.DrawText(text);
            };
            Pipeline.Run(reader + drawer + writer);
        }
    }
}
```
 
## See Also
  
### Reference
 
- [Pipeline Class](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Pipeline.htm.md)
- [Drawer Class](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Drawer.htm.md)
- [Draw Event](https://www.graphicsmill.com/docs/gm/E_Aurigma_GraphicsMill_Drawing_Drawer_Draw.htm.md)
- [Graphics Class](https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Graphics.htm.md)

### Manual
 
- [Drawing Text and Graphics](https://www.graphicsmill.com/docs/gm/advanced-drawing.htm.md)
- [Graphics: Drawing Images and Geometric Shapes](https://www.graphicsmill.com/docs/gm/graphics.htm.md)
- [Transforming Images with Pipelines](https://www.graphicsmill.com/docs/gm/transforming-images-with-pipelines.htm.md)
- [EXIF and IPTC Metadata](https://www.graphicsmill.com/docs/gm/exif-and-iptc-metadata.htm.md)
