aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Providers/DynamicImageResponse.cs
blob: 66fddb0e38bff98510a9324348a0999c7c44ab26 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#nullable disable

#pragma warning disable CS1591

using System;
using System.IO;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.MediaInfo;

namespace MediaBrowser.Controller.Providers
{
    public class DynamicImageResponse
    {
        public string Path { get; set; }

        public MediaProtocol Protocol { get; set; }

        public Stream Stream { get; set; }

        public ImageFormat Format { get; set; }

        public bool HasImage { get; set; }

        public void SetFormatFromMimeType(string mimeType)
        {
            if (mimeType.EndsWith("gif", StringComparison.OrdinalIgnoreCase))
            {
                Format = ImageFormat.Gif;
            }
            else if (mimeType.EndsWith("bmp", StringComparison.OrdinalIgnoreCase))
            {
                Format = ImageFormat.Bmp;
            }
            else if (mimeType.EndsWith("png", StringComparison.OrdinalIgnoreCase))
            {
                Format = ImageFormat.Png;
            }
            else
            {
                Format = ImageFormat.Jpg;
            }
        }
    }
}