From dc222b75c55645fce521c572acebb16b278169a5 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Tue, 4 Jan 2022 10:40:16 +0100 Subject: Remove incorrect mime type image/jpg --- .../Drawing/ImageFormatExtensions.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 MediaBrowser.Model/Drawing/ImageFormatExtensions.cs (limited to 'MediaBrowser.Model/Drawing/ImageFormatExtensions.cs') diff --git a/MediaBrowser.Model/Drawing/ImageFormatExtensions.cs b/MediaBrowser.Model/Drawing/ImageFormatExtensions.cs new file mode 100644 index 000000000..68a5c2534 --- /dev/null +++ b/MediaBrowser.Model/Drawing/ImageFormatExtensions.cs @@ -0,0 +1,27 @@ +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)) + }; +} -- cgit v1.2.3