aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Images/ImageService.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-09-07 14:18:09 -0400
committerGitHub <noreply@github.com>2017-09-07 14:18:09 -0400
commit890069d312d3132391edf857730ffc9a34c9fce4 (patch)
treea46e31f6f2d155411a24e4ff3685013512a078e9 /MediaBrowser.Api/Images/ImageService.cs
parent5116b175ce4a1f3a54c64c6f8fa8e8fba1a69e1a (diff)
parent6392f5e141b9971f7d69cc74e08118889d6d5580 (diff)
Merge pull request #2869 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Api/Images/ImageService.cs')
-rw-r--r--MediaBrowser.Api/Images/ImageService.cs47
1 files changed, 5 insertions, 42 deletions
diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs
index 69d4a4ab4..f8481517d 100644
--- a/MediaBrowser.Api/Images/ImageService.cs
+++ b/MediaBrowser.Api/Images/ImageService.cs
@@ -567,7 +567,7 @@ namespace MediaBrowser.Api.Images
cropwhitespace = request.CropWhitespace.Value;
}
- var outputFormats = GetOutputFormats(request, imageInfo, cropwhitespace, supportedImageEnhancers);
+ var outputFormats = GetOutputFormats(request);
TimeSpan? cacheDuration = null;
@@ -597,7 +597,7 @@ namespace MediaBrowser.Api.Images
ImageRequest request,
ItemImageInfo image,
bool cropwhitespace,
- List<ImageFormat> supportedFormats,
+ ImageFormat[] supportedFormats,
List<IImageEnhancer> enhancers,
TimeSpan? cacheDuration,
IDictionary<string, string> headers,
@@ -644,55 +644,18 @@ namespace MediaBrowser.Api.Images
}).ConfigureAwait(false);
}
- private List<ImageFormat> GetOutputFormats(ImageRequest request, ItemImageInfo image, bool cropwhitespace, List<IImageEnhancer> enhancers)
+ private ImageFormat[] GetOutputFormats(ImageRequest request)
{
if (!string.IsNullOrWhiteSpace(request.Format))
{
ImageFormat format;
if (Enum.TryParse(request.Format, true, out format))
{
- return new List<ImageFormat> { format };
+ return new ImageFormat[] { format };
}
}
- var extension = Path.GetExtension(image.Path);
- ImageFormat? inputFormat = null;
-
- if (string.Equals(extension, ".jpg", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(extension, ".jpeg", StringComparison.OrdinalIgnoreCase))
- {
- inputFormat = ImageFormat.Jpg;
- }
- else if (string.Equals(extension, ".png", StringComparison.OrdinalIgnoreCase))
- {
- inputFormat = ImageFormat.Png;
- }
-
- var clientSupportedFormats = GetClientSupportedFormats();
-
- var serverFormats = _imageProcessor.GetSupportedImageOutputFormats();
- var outputFormats = new List<ImageFormat>();
-
- // Client doesn't care about format, so start with webp if supported
- if (serverFormats.Contains(ImageFormat.Webp) && clientSupportedFormats.Contains(ImageFormat.Webp))
- {
- outputFormats.Add(ImageFormat.Webp);
- }
-
- if (enhancers.Count > 0)
- {
- outputFormats.Add(ImageFormat.Png);
- }
-
- if (inputFormat.HasValue && inputFormat.Value == ImageFormat.Jpg)
- {
- outputFormats.Add(ImageFormat.Jpg);
- }
-
- // We can't predict if there will be transparency or not, so play it safe
- outputFormats.Add(ImageFormat.Png);
-
- return outputFormats;
+ return GetClientSupportedFormats();
}
private ImageFormat[] GetClientSupportedFormats()