-
Notifications
You must be signed in to change notification settings - Fork 1
/
MimeDetection.cs
27 lines (23 loc) · 900 Bytes
/
MimeDetection.cs
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
using System;
using System.Drawing.Imaging;
namespace Kirinnee.ImageOrchestrator
{
public static class MimeDetection
{
public static ImageFormat GetImageFormatFromMime(this string mimeType)
{
switch (mimeType)
{
case "image/png": return ImageFormat.Png;
case "image/jpeg": return ImageFormat.Jpeg;
case "image/bmp": return ImageFormat.Bmp;
case "image/gif": return ImageFormat.Gif;
case "image/x-icon": return ImageFormat.Icon;
case "image/tiff": return ImageFormat.Tiff;
case "application/x-msmetafile": return ImageFormat.Wmf;
case "image/x-emf": return ImageFormat.Emf;
default : throw new FormatException("Unknown image mime type: "+ mimeType);
}
}
}
}