---
title: "Write Extra Channel"
canonical: https://www.graphicsmill.com/samples/Codecs/Tiff/WriteExtraChannel_cs
product: "Graphics Mill"
source: "Codecs/Tiff/WriteExtraChannel.cs"
---

# Write Extra Channel

Creates a TIFF image with an extra channel.

## Instruction

Add an extra alpha channel to a base TIFF image using a grayscale bitmap as the source.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
```

## Code Snippet

```csharp
using (var reader = new TiffReader("Copenhagen_Resized.tif"))
using (var writer = new TiffWriter("CopenhagenWithExtraChannel.tif"))
{
    // Load bitmap for the extra channel.
    // Note: image for extra channel must be grayscale and have the same dimensions and DPI as the source one.
    using (var extraBitmap = new Bitmap("Copenhagen_Extra.tif"))
    {
        // Create extra channel options based on extraBitmap.
        var extraChannel = new TiffExtraChannelEntry(extraBitmap, TiffChannelType.Alpha);

        writer.ExtraChannels.Add(extraChannel);
        Pipeline.Run(reader + writer);
    }
}
```

## Explanation

The following code reads a base TIFF file and adds an extra grayscale image as an alpha channel, then saves the result:

Ensure the extra channel image is grayscale and matches the base image in size and DPI.

## Tags

- [Bitmap](<https://www.graphicsmill.com/samples/tags/bitmap_md>): Working with images via the Bitmap API
- [Extra Channels](<https://www.graphicsmill.com/samples/tags/extra-channels_md>): Working with TIFF extra channels
- [TIFF](<https://www.graphicsmill.com/samples/tags/tiff_md>): Reading and writing TIFF images
- [Write](<https://www.graphicsmill.com/samples/tags/write_md>): Writing images with codecs

## Input

- [Copenhagen\_Resized.tif](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/Copenhagen_Resized_tif>) (download)
- [Copenhagen\_Extra.tif](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/Copenhagen_Extra_tif>) (download)

## Output

- [CopenhagenWithExtraChannel.tif](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/CopenhagenWithExtraChannel_tif>) (download)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.TiffChannelType](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_TiffChannelType.htm.md>)
- [Aurigma.GraphicsMill.Codecs.TiffExtraChannelEntry](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_TiffExtraChannelEntry.htm.md>)
- [Aurigma.GraphicsMill.Codecs.TiffReader](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_TiffReader.htm.md>)
- [Aurigma.GraphicsMill.Codecs.TiffWriter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_TiffWriter.htm.md>)
- [Aurigma.GraphicsMill.Codecs.TiffWriter.ExtraChannels](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_TiffWriter_ExtraChannels.htm.md>)
