---
title: "Write Extra Channel With Name"
canonical: https://www.graphicsmill.com/samples/Codecs/Tiff/WriteExtraChannelWithName_cs
product: "Graphics Mill"
source: "Codecs/Tiff/WriteExtraChannelWithName.cs"
---

# Write Extra Channel With Name

Save the name of an extra channel to Adobe Resources.

## Instruction

Save an extra channel with a custom name to a TIFF image using Adobe resources.

## Usings

```csharp
using System.Collections.Generic;
using Aurigma.GraphicsMill.Codecs;
```

## Code Snippet

```csharp
public static void Run()
{
    string channelName = "MyChannelName";

    using (var reader = new TiffReader("Copenhagen_Resized.tif"))
    using (var writer = new TiffWriter("BusinessCardExtraChannelWithName.tif"))
    using (var extraChannel = new Bitmap(reader.Width, reader.Height, PixelFormat.Format8bppGrayscale))
    {
        writer.ExtraChannels.Add(new TiffExtraChannelEntry(extraChannel, TiffChannelType.Color));

        var ar = new AdobeResourceDictionary();

        // https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
        const int unicodeAlphaNames = 0x0415;

        ar[unicodeAlphaNames] = ChannelNameToResource(channelName);
        writer.AdobeResources = ar;
        Pipeline.Run(reader + writer);
    }
}

private static AdobeResourceBlock ChannelNameToResource(string name)
{
    var arr = new List<byte>();

    arr.AddRange(new byte[] { 0, 0 });
    arr.AddRange(new byte[] { 0, (byte)(name.Length + 1) });

    foreach (var ch in name)
    {
        arr.AddRange(new byte[] { 0, (byte)ch });
    }

    arr.AddRange(new byte[] { 0, 0 });

    return new AdobeResourceBlock(string.Empty, arr.ToArray());
}
```

## Explanation

The following code:

- Adds a grayscale extra channel to a base TIFF image.
- Assigns the channel type as `Color`.
- Encodes the name `"MyChannelName"` using the Adobe Photoshop resource ID `0x0415` for Unicode Alpha Names.
- Stores this information in the `AdobeResourceDictionary` associated with the TIFF writer.
This ensures that the extra channel has a meaningful label that compatible applications can recognize.

## Tags

- [Adobe Resources](<https://www.graphicsmill.com/samples/tags/adobe-resources_md>): Working with Adobe image resource blocks
- [Extra Channels](<https://www.graphicsmill.com/samples/tags/extra-channels_md>): Working with TIFF extra channels
- [Pipeline](<https://www.graphicsmill.com/samples/tags/pipeline_md>): Working with images via the Pipeline API
- [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)

## Output

- [BusinessCardExtraChannelWithName.tif](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/BusinessCardExtraChannelWithName_tif>) (download)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.AdobeResourceBlock](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_AdobeResourceBlock.htm.md>)
- [Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_AdobeResourceDictionary.htm.md>)
- [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.AdobeResources](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_TiffWriter_AdobeResources.htm.md>)
- [Aurigma.GraphicsMill.Codecs.TiffWriter.ExtraChannels](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_TiffWriter_ExtraChannels.htm.md>)
