Tag Archives: GDI+

ImageCodecInfo: Encoder and Decoder information

If you’ve ever been curious about the GDI+ encoders and decoders available on your system, you can call ImageCodecInfo.GetImageEncoders() and ImageCodecInfo.GetImageDecoders(), respectively, to find out more:

Encoders:

ImageCodecInfo.GetImageEncoders().ToList().ForEach(
    enc =>
    {
        Console.WriteLine(enc.FormatDescription);
        Console.WriteLine("tCLSID: {0}", enc.Clsid);
        Console.WriteLine("tCodecName: {0}", enc.CodecName);
        Console.WriteLine("tFilenameExtension: {0}", enc.FilenameExtension);
        Console.WriteLine("tFlags: {0}", enc.Flags);
        Console.WriteLine("tFormatDescription: {0}", enc.FormatDescription);
        Console.WriteLine("tFormatID: {0}", enc.FormatID);
        Console.WriteLine("tMimeType: {0}", enc.MimeType);
        Console.WriteLine("tVersion: {0}", enc.Version);
    });

On my Windows Server 2008 machine, the above code returns the following:

BMP
        CLSID: 557cf400-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in BMP Codec
        FilenameExtension: *.BMP;*.DIB;*.RLE
        Flags: Encoder, Decoder, SupportBitmap, Builtin
        FormatDescription: BMP
        FormatID: b96b3cab-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/bmp
        Version: 1
JPEG
        CLSID: 557cf401-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in JPEG Codec
        FilenameExtension: *.JPG;*.JPEG;*.JPE;*.JFIF
        Flags: Encoder, Decoder, SupportBitmap, Builtin
        FormatDescription: JPEG
        FormatID: b96b3cae-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/jpeg
        Version: 1
GIF
        CLSID: 557cf402-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in GIF Codec
        FilenameExtension: *.GIF
        Flags: Encoder, Decoder, SupportBitmap, Builtin
        FormatDescription: GIF
        FormatID: b96b3cb0-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/gif
        Version: 1
TIFF
        CLSID: 557cf405-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in TIFF Codec
        FilenameExtension: *.TIF;*.TIFF
        Flags: Encoder, Decoder, SupportBitmap, Builtin
        FormatDescription: TIFF
        FormatID: b96b3cb1-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/tiff
        Version: 1
PNG
        CLSID: 557cf406-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in PNG Codec
        FilenameExtension: *.PNG
        Flags: Encoder, Decoder, SupportBitmap, Builtin
        FormatDescription: PNG
        FormatID: b96b3caf-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/png
        Version: 1

Decoders:

ImageCodecInfo.GetImageDecoders().ToList().ForEach(
    enc =>
    {
        Console.WriteLine(enc.FormatDescription);
        Console.WriteLine("tCLSID: {0}", enc.Clsid);
        Console.WriteLine("tCodecName: {0}", enc.CodecName);
        Console.WriteLine("tFilenameExtension: {0}", enc.FilenameExtension);
        Console.WriteLine("tFlags: {0}", enc.Flags);
        Console.WriteLine("tFormatDescription: {0}", enc.FormatDescription);
        Console.WriteLine("tFormatID: {0}", enc.FormatID);
        Console.WriteLine("tMimeType: {0}", enc.MimeType);
        Console.WriteLine("tVersion: {0}", enc.Version);
    });

Again, on my Windows Server 2008 box, the above code returns the following:

BMP
        CLSID: 557cf400-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in BMP Codec
        FilenameExtension: *.BMP;*.DIB;*.RLE
        Flags: Encoder, Decoder, SupportBitmap, Builtin
        FormatDescription: BMP
        FormatID: b96b3cab-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/bmp
        Version: 1
JPEG
        CLSID: 557cf401-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in JPEG Codec
        FilenameExtension: *.JPG;*.JPEG;*.JPE;*.JFIF
        Flags: Encoder, Decoder, SupportBitmap, Builtin
        FormatDescription: JPEG
        FormatID: b96b3cae-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/jpeg
        Version: 1
GIF
        CLSID: 557cf402-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in GIF Codec
        FilenameExtension: *.GIF
        Flags: Encoder, Decoder, SupportBitmap, Builtin
        FormatDescription: GIF
        FormatID: b96b3cb0-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/gif
        Version: 1
EMF
        CLSID: 557cf403-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in EMF Codec
        FilenameExtension: *.EMF
        Flags: Decoder, SupportBitmap, Builtin
        FormatDescription: EMF
        FormatID: b96b3cac-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/x-emf
        Version: 1
WMF
        CLSID: 557cf404-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in WMF Codec
        FilenameExtension: *.WMF
        Flags: Decoder, SupportBitmap, Builtin
        FormatDescription: WMF
        FormatID: b96b3cad-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/x-wmf
        Version: 1
TIFF
        CLSID: 557cf405-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in TIFF Codec
        FilenameExtension: *.TIF;*.TIFF
        Flags: Encoder, Decoder, SupportBitmap, Builtin
        FormatDescription: TIFF
        FormatID: b96b3cb1-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/tiff
        Version: 1
PNG
        CLSID: 557cf406-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in PNG Codec
        FilenameExtension: *.PNG
        Flags: Encoder, Decoder, SupportBitmap, Builtin
        FormatDescription: PNG
        FormatID: b96b3caf-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/png
        Version: 1
ICO
        CLSID: 557cf407-1a04-11d3-9a73-0000f81ef32e
        CodecName: Built-in ICO Codec
        FilenameExtension: *.ICO
        Flags: Decoder, SupportBitmap, Builtin
        FormatDescription: ICO
        FormatID: b96b3cb5-0728-11d3-9d7b-0000f81ef32e
        MimeType: image/x-icon
        Version: 1

ImageCodecInfo is located in System.Drawing.Imaging.

Why am I writing this? On more than one occasion, I have found myself writing code to enumerate these values; I’d rather just have a place to look them up.