ImageCodecInfo: Encoder and Decoder information

Posted January 25, 2010 in c# gdi+ imaging
Reading time: 3 minutes

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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.



Comments

comments powered by Disqus