using System.ComponentModel; using System.Net.Mime; namespace MediaBrowser.Model.Drawing; /// /// Extension class for the enum. /// public static class ImageFormatExtensions { /// /// Returns the correct mime type for this . /// /// This . /// The is an invalid enumeration value. /// The correct mime type for this . public static string GetMimeType(this ImageFormat format) => format switch { ImageFormat.Bmp => "image/bmp", ImageFormat.Gif => MediaTypeNames.Image.Gif, ImageFormat.Jpg => MediaTypeNames.Image.Jpeg, ImageFormat.Png => "image/png", ImageFormat.Webp => "image/webp", _ => throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(ImageFormat)) }; /// /// Returns the correct extension for this . /// /// This . /// The is an invalid enumeration value. /// The correct extension for this . public static string GetExtension(this ImageFormat format) => format switch { ImageFormat.Bmp => ".bmp", ImageFormat.Gif => ".gif", ImageFormat.Jpg => ".jpg", ImageFormat.Png => ".png", ImageFormat.Webp => ".webp", _ => throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(ImageFormat)) }; }