aboutsummaryrefslogtreecommitdiff
path: root/Emby.Drawing/ImageProcessor.cs
diff options
context:
space:
mode:
authorAndrew Rabert <6550543+nvllsvm@users.noreply.github.com>2019-01-19 22:42:46 -0500
committerGitHub <noreply@github.com>2019-01-19 22:42:46 -0500
commit65610219265e5cfe6137d997cf298fb3c88a6a88 (patch)
tree93d9b0dad7e241dff8a1c46fe004af72ee1b6500 /Emby.Drawing/ImageProcessor.cs
parentd72d0fb865f2eccef4f96a6ebc5f1e409778608f (diff)
parent875392c77fce26f2b51142f65998a1d73727310b (diff)
Merge pull request #582 from nvllsvm/image
Replace custom image parser with Skia
Diffstat (limited to 'Emby.Drawing/ImageProcessor.cs')
-rw-r--r--Emby.Drawing/ImageProcessor.cs34
1 files changed, 13 insertions, 21 deletions
diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs
index 28aae9cae..f91990442 100644
--- a/Emby.Drawing/ImageProcessor.cs
+++ b/Emby.Drawing/ImageProcessor.cs
@@ -1,3 +1,4 @@
+using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -5,7 +6,6 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Emby.Drawing.Common;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Drawing;
@@ -422,10 +422,10 @@ namespace Emby.Drawing
public ImageSize GetImageSize(BaseItem item, ItemImageInfo info)
{
- return GetImageSize(item, info, false, true);
+ return GetImageSize(item, info, true);
}
- public ImageSize GetImageSize(BaseItem item, ItemImageInfo info, bool allowSlowMethods, bool updateItem)
+ public ImageSize GetImageSize(BaseItem item, ItemImageInfo info, bool updateItem)
{
var width = info.Width;
var height = info.Height;
@@ -442,7 +442,7 @@ namespace Emby.Drawing
var path = info.Path;
_logger.LogInformation("Getting image size for item {0} {1}", item.GetType().Name, path);
- var size = GetImageSize(path, allowSlowMethods);
+ var size = GetImageSize(path);
info.Height = Convert.ToInt32(size.Height);
info.Width = Convert.ToInt32(size.Width);
@@ -455,34 +455,26 @@ namespace Emby.Drawing
return size;
}
- public ImageSize GetImageSize(string path)
- {
- return GetImageSize(path, true);
- }
-
/// <summary>
/// Gets the size of the image.
/// </summary>
- private ImageSize GetImageSize(string path, bool allowSlowMethod)
+ public ImageSize GetImageSize(string path)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException(nameof(path));
}
- try
- {
- return ImageHeader.GetDimensions(path, _logger, _fileSystem);
- }
- catch
- {
- if (!allowSlowMethod)
+ using (var s = new SKFileStream(path))
+ using (var codec = SKCodec.Create(s))
{
- throw;
+ var info = codec.Info;
+ return new ImageSize
+ {
+ Height = info.Height,
+ Width = info.Width
+ };
}
- }
-
- return _imageEncoder.GetImageSize(path);
}
/// <summary>