aboutsummaryrefslogtreecommitdiff
path: root/Emby.Drawing
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Drawing')
-rw-r--r--Emby.Drawing/ImageProcessor.cs18
-rw-r--r--Emby.Drawing/NullImageEncoder.cs15
2 files changed, 15 insertions, 18 deletions
diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs
index 097b4c40b..1e4646227 100644
--- a/Emby.Drawing/ImageProcessor.cs
+++ b/Emby.Drawing/ImageProcessor.cs
@@ -83,8 +83,8 @@ namespace Emby.Drawing
}
}
- public string[] SupportedInputFormats =>
- new string[]
+ public IReadOnlyCollection<string> SupportedInputFormats =>
+ new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"tiff",
"tif",
@@ -137,14 +137,14 @@ namespace Emby.Drawing
}
}
- public ImageFormat[] GetSupportedImageOutputFormats()
- {
- return _imageEncoder.SupportedOutputFormats;
- }
+ public IReadOnlyCollection<ImageFormat> GetSupportedImageOutputFormats()
+ => _imageEncoder.SupportedOutputFormats;
+
+ private static readonly HashSet<string> TransparentImageTypes
+ = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".png", ".webp", ".gif" };
- private static readonly string[] TransparentImageTypes = new string[] { ".png", ".webp", ".gif" };
public bool SupportsTransparency(string path)
- => TransparentImageTypes.Contains(Path.GetExtension(path).ToLowerInvariant());
+ => TransparentImageTypes.Contains(Path.GetExtension(path));
public async Task<(string path, string mimeType, DateTime dateModified)> ProcessImage(ImageProcessingOptions options)
{
@@ -472,7 +472,7 @@ namespace Emby.Drawing
return (originalImagePath, dateModified);
}
- if (!_imageEncoder.SupportedInputFormats.Contains(inputFormat, StringComparer.OrdinalIgnoreCase))
+ if (!_imageEncoder.SupportedInputFormats.Contains(inputFormat))
{
try
{
diff --git a/Emby.Drawing/NullImageEncoder.cs b/Emby.Drawing/NullImageEncoder.cs
index 14f0424ac..fc4a5af9f 100644
--- a/Emby.Drawing/NullImageEncoder.cs
+++ b/Emby.Drawing/NullImageEncoder.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Model.Drawing;
@@ -6,15 +7,11 @@ namespace Emby.Drawing
{
public class NullImageEncoder : IImageEncoder
{
- public string[] SupportedInputFormats =>
- new[]
- {
- "png",
- "jpeg",
- "jpg"
- };
-
- public ImageFormat[] SupportedOutputFormats => new[] { ImageFormat.Jpg, ImageFormat.Png };
+ public IReadOnlyCollection<string> SupportedInputFormats
+ => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "png", "jpeg", "jpg" };
+
+ public IReadOnlyCollection<ImageFormat> SupportedOutputFormats
+ => new HashSet<ImageFormat>() { ImageFormat.Jpg, ImageFormat.Png };
public void CropWhiteSpace(string inputPath, string outputPath)
{