diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-11-12 14:26:02 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-11-12 14:26:02 -0500 |
| commit | 90e06289dc8a9b97fc48ee136eade94616de1ad6 (patch) | |
| tree | 8ecf6d82b53011502fbb840db9ed4328aabbaeea /MediaBrowser.Controller | |
| parent | 4da6275de121c7f8f1d82100588173039e8d0824 (diff) | |
update image encoding
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Drawing/IImageProcessor.cs | 11 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs | 41 |
2 files changed, 41 insertions, 11 deletions
diff --git a/MediaBrowser.Controller/Drawing/IImageProcessor.cs b/MediaBrowser.Controller/Drawing/IImageProcessor.cs index e1e98857f..d42a04f2e 100644 --- a/MediaBrowser.Controller/Drawing/IImageProcessor.cs +++ b/MediaBrowser.Controller/Drawing/IImageProcessor.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Entities; @@ -18,7 +19,7 @@ namespace MediaBrowser.Controller.Drawing /// </summary> /// <value>The supported input formats.</value> string[] SupportedInputFormats { get; } - + /// <summary> /// Gets the image enhancers. /// </summary> @@ -38,7 +39,7 @@ namespace MediaBrowser.Controller.Drawing /// <param name="path">The path.</param> /// <returns>ImageSize.</returns> ImageSize GetImageSize(string path); - + /// <summary> /// Adds the parts. /// </summary> @@ -77,13 +78,13 @@ namespace MediaBrowser.Controller.Drawing /// <param name="toStream">To stream.</param> /// <returns>Task.</returns> Task ProcessImage(ImageProcessingOptions options, Stream toStream); - + /// <summary> /// Processes the image. /// </summary> /// <param name="options">The options.</param> /// <returns>Task.</returns> - Task<string> ProcessImage(ImageProcessingOptions options); + Task<Tuple<string, string>> ProcessImage(ImageProcessingOptions options); /// <summary> /// Gets the enhanced image. diff --git a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs index d8f5d52c3..2b80b701e 100644 --- a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs +++ b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs @@ -4,6 +4,7 @@ using MediaBrowser.Model.Drawing; using System; using System.Collections.Generic; using System.IO; +using System.Linq; namespace MediaBrowser.Controller.Drawing { @@ -25,11 +26,11 @@ namespace MediaBrowser.Controller.Drawing public int? MaxHeight { get; set; } - public int? Quality { get; set; } + public int Quality { get; set; } public List<IImageEnhancer> Enhancers { get; set; } - public ImageFormat OutputFormat { get; set; } + public List<ImageFormat> SupportedOutputFormats { get; set; } public bool AddPlayedIndicator { get; set; } @@ -48,19 +49,47 @@ namespace MediaBrowser.Controller.Drawing !MaxHeight.HasValue; } + public bool HasDefaultOptions(string originalImagePath, ImageSize size) + { + if (!HasDefaultOptionsWithoutSize(originalImagePath)) + { + return false; + } + + if (Width.HasValue && !size.Width.Equals(Width.Value)) + { + return false; + } + if (Height.HasValue && !size.Height.Equals(Height.Value)) + { + return false; + } + if (MaxWidth.HasValue && size.Width > MaxWidth.Value) + { + return false; + } + if (MaxHeight.HasValue && size.Height > MaxHeight.Value) + { + return false; + } + + return true; + } + public bool HasDefaultOptionsWithoutSize(string originalImagePath) { - return (!Quality.HasValue || Quality.Value == 100) && - IsOutputFormatDefault(originalImagePath) && + return (Quality >= 90) && + IsFormatSupported(originalImagePath) && !AddPlayedIndicator && PercentPlayed.Equals(0) && !UnplayedCount.HasValue && string.IsNullOrEmpty(BackgroundColor); } - private bool IsOutputFormatDefault(string originalImagePath) + private bool IsFormatSupported(string originalImagePath) { - return string.Equals(Path.GetExtension(originalImagePath), "." + OutputFormat, StringComparison.OrdinalIgnoreCase); + var ext = Path.GetExtension(originalImagePath); + return SupportedOutputFormats.Any(outputFormat => string.Equals(ext, "." + outputFormat, StringComparison.OrdinalIgnoreCase)); } } } |
