---
title: "Write Animated WebP"
canonical: https://www.graphicsmill.com/samples/Codecs/WebP/WriteAnimatedWebP_cs
product: "Graphics Mill"
source: "Codecs/WebP/WriteAnimatedWebP.cs"
---

# Write Animated WebP

Writes simple animated image in WebP format.

## Instruction

Writes a simple animated image in WebP format using generated bitmap frames.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
using (var writer = new WebPWriter("WriteAnimatedWebP.webp"))
{
    writer.FrameOptions.Delay = 250;

    for (int i = 0; i < 400; i += 25)
    {
        var bitmap = new Bitmap(400, 100, PixelFormat.Format24bppRgb, RgbColor.Yellow);

        using (var graphics = bitmap.GetGraphics())
        {
            graphics.FillEllipse(new SolidBrush(RgbColor.Green), new System.Drawing.RectangleF(i, 0, 100, 100));
        }

        Pipeline.Run(bitmap + writer);
    }
}
```

## Explanation

The following code:

- Creates a new WebP animation with a frame delay of 250 milliseconds.
- Loops through positions horizontally from 0 to 375, incrementing by 25.
- For each frame, creates a 400x100 yellow bitmap.
- Draws a green ellipse at the current position to simulate animation.
- Writes each frame to the WebP output using `Pipeline.Run()` for efficient streaming.

## Tags

- [Drawing](<https://www.graphicsmill.com/samples/tags/drawing_md>): Drawing vector shapes and text
- [Multiple frames](<https://www.graphicsmill.com/samples/tags/multi-frame_md>): Handling multi-frame image formats
- [Pipeline](<https://www.graphicsmill.com/samples/tags/pipeline_md>): Working with images via the Pipeline API
- [WEBP](<https://www.graphicsmill.com/samples/tags/webp_md>): Reading and writing WebP images

## Output

- [WriteAnimatedWebP.webp](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/WriteAnimatedWebP_webp>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Codecs.WebPFrameSettings.Delay](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_WebPFrameSettings_Delay.htm.md>)
- [Aurigma.GraphicsMill.Codecs.WebPWriter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_WebPWriter.htm.md>)
- [Aurigma.GraphicsMill.Codecs.WebPWriter.FrameOptions](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_WebPWriter_FrameOptions.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.FillEllipse(Brush,RectangleF)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_FillEllipse_2_9763ccb2.htm.md>)
- [Aurigma.GraphicsMill.Drawing.SolidBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_SolidBrush.htm.md>)
