aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Providers/DynamicImageResponse.cs
blob: 71a937cd9de220a40c62460c8dcf8739ad1d2c09 (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
using System;
using System.IO;
using MediaBrowser.Model.Drawing;

namespace MediaBrowser.Controller.Providers
{
    public class DynamicImageResponse
    {
        public string Path { get; set; }
        public Stream Stream { get; set; }
        public ImageFormat Format { get; set; }
        public bool HasImage { get; set; }
        public string InternalCacheKey { 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;
            }
        }
    }
}