mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 09:04:42 +01:00
reduce image processing
This commit is contained in:
@@ -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;
|
||||
@@ -83,7 +84,7 @@ namespace MediaBrowser.Controller.Drawing
|
||||
/// </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.
|
||||
|
||||
@@ -4,6 +4,7 @@ using MediaBrowser.Model.Drawing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Controller.Drawing
|
||||
{
|
||||
@@ -29,7 +30,7 @@ namespace MediaBrowser.Controller.Drawing
|
||||
|
||||
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 == 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user