aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs
blob: 506d6fd3d2c82b28d02ffaf46d3825adf651dcd4 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;

namespace MediaBrowser.Controller.Drawing
{
    public class ImageProcessingOptions
    {
        public IHasImages Item { get; set; }

        public ImageType ImageType { get; set; }

        public int ImageIndex { get; set; }

        public string OriginalImagePath { get; set; }

        public DateTime OriginalImageDateModified { get; set; }

        public bool CropWhiteSpace { get; set; }

        public int? Width { get; set; }

        public int? Height { get; set; }

        public int? MaxWidth { get; set; }

        public int? MaxHeight { get; set; }

        public int? Quality { get; set; }

        public List<IImageEnhancer> Enhancers { get; set; }

        public ImageOutputFormat OutputFormat { get; set; }

        public bool AddPlayedIndicator { get; set; }

        public int? PercentPlayed { get; set; }

        public string BackgroundColor { get; set; }

        public bool HasDefaultOptions()
        {
            return HasDefaultOptionsWithoutSize() && 
                !Width.HasValue && 
                !Height.HasValue && 
                !MaxWidth.HasValue && 
                !MaxHeight.HasValue;
        }

        public bool HasDefaultOptionsWithoutSize()
        {
            return (!Quality.HasValue || Quality.Value == 100) &&
                IsOutputFormatDefault &&
                !AddPlayedIndicator &&
                !PercentPlayed.HasValue &&
                string.IsNullOrEmpty(BackgroundColor);
        }

        private bool IsOutputFormatDefault
        {
            get
            {
                if (OutputFormat == ImageOutputFormat.Original)
                {
                    return true;
                }

                return false;
            }
        }
    }
}