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 => MediaTypeNames.Image.Bmp,
ImageFormat.Gif => MediaTypeNames.Image.Gif,
ImageFormat.Jpg => MediaTypeNames.Image.Jpeg,
ImageFormat.Png => MediaTypeNames.Image.Png,
ImageFormat.Webp => MediaTypeNames.Image.Webp,
ImageFormat.Svg => MediaTypeNames.Image.Svg,
_ => 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))
};
}