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",
ImageFormat.Svg => "image/svg+xml",
_ => 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",
ImageFormat.Svg => ".svg",
_ => throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(ImageFormat))
};
}