mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-16 05:53:03 +03:00
reduce image processing
This commit is contained in:
@@ -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