From d577e1c7b01c45bca49cb47a1af3697f904f9e4d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 16 Oct 2015 13:06:31 -0400 Subject: support image stubbing --- Emby.Drawing/ImageProcessor.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'Emby.Drawing/ImageProcessor.cs') diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 120a4cedb..af086ce6d 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -18,6 +18,7 @@ using System.Threading; using System.Threading.Tasks; using CommonIO; using Emby.Drawing.Common; +using MediaBrowser.Controller.Library; namespace Emby.Drawing { @@ -53,18 +54,20 @@ namespace Emby.Drawing private readonly IServerApplicationPaths _appPaths; private readonly IImageEncoder _imageEncoder; private readonly SemaphoreSlim _imageProcessingSemaphore; + private readonly Func _libraryManager; public ImageProcessor(ILogger logger, IServerApplicationPaths appPaths, IFileSystem fileSystem, IJsonSerializer jsonSerializer, IImageEncoder imageEncoder, - int maxConcurrentImageProcesses) + int maxConcurrentImageProcesses, Func libraryManager) { _logger = logger; _fileSystem = fileSystem; _jsonSerializer = jsonSerializer; _imageEncoder = imageEncoder; + _libraryManager = libraryManager; _appPaths = appPaths; ImageEnhancers = new List(); @@ -158,7 +161,14 @@ namespace Emby.Drawing throw new ArgumentNullException("options"); } - var originalImagePath = options.Image.Path; + var originalImage = options.Image; + + if (!originalImage.IsLocalFile) + { + originalImage = await _libraryManager().ConvertImageToLocal(options.Item, originalImage, options.ImageIndex).ConfigureAwait(false); + } + + var originalImagePath = originalImage.Path; if (options.HasDefaultOptions(originalImagePath) && options.Enhancers.Count == 0 && !options.CropWhiteSpace) { @@ -166,7 +176,7 @@ namespace Emby.Drawing return originalImagePath; } - var dateModified = options.Image.DateModified; + var dateModified = originalImage.DateModified; if (options.CropWhiteSpace) { @@ -181,7 +191,7 @@ namespace Emby.Drawing var tuple = await GetEnhancedImage(new ItemImageInfo { DateModified = dateModified, - Type = options.Image.Type, + Type = originalImage.Type, Path = originalImagePath }, options.Item, options.ImageIndex, options.Enhancers).ConfigureAwait(false); @@ -360,16 +370,6 @@ namespace Emby.Drawing return GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLower()); } - /// - /// Gets the size of the image. - /// - /// The path. - /// ImageSize. - public ImageSize GetImageSize(string path) - { - return GetImageSize(path, _fileSystem.GetLastWriteTimeUtc(path), false); - } - public ImageSize GetImageSize(ItemImageInfo info) { return GetImageSize(info.Path, info.DateModified, false); -- cgit v1.2.3 From bb5c5297c538908ca9624104507d7fba179568d1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 16 Oct 2015 15:20:59 -0400 Subject: fixes #1212 - Visual bug for some movies --- Emby.Drawing/ImageProcessor.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'Emby.Drawing/ImageProcessor.cs') diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index af086ce6d..30a8334d2 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -800,7 +800,6 @@ namespace Emby.Drawing return false; } - }); } -- cgit v1.2.3 From d1195257aa6ffa8086ce6461183442ffa28365f3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 16 Oct 2015 15:25:19 -0400 Subject: fix for cover art --- Emby.Drawing/ImageProcessor.cs | 5 +++++ MediaBrowser.Controller/Drawing/IImageProcessor.cs | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'Emby.Drawing/ImageProcessor.cs') diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 30a8334d2..8ceec8529 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -375,6 +375,11 @@ namespace Emby.Drawing return GetImageSize(info.Path, info.DateModified, false); } + public ImageSize GetImageSize(string path) + { + return GetImageSize(path, _fileSystem.GetLastWriteTimeUtc(path), false); + } + /// /// Gets the size of the image. /// diff --git a/MediaBrowser.Controller/Drawing/IImageProcessor.cs b/MediaBrowser.Controller/Drawing/IImageProcessor.cs index 838dfc9fb..fea6b979d 100644 --- a/MediaBrowser.Controller/Drawing/IImageProcessor.cs +++ b/MediaBrowser.Controller/Drawing/IImageProcessor.cs @@ -32,6 +32,13 @@ namespace MediaBrowser.Controller.Drawing /// ImageSize. ImageSize GetImageSize(ItemImageInfo info); + /// + /// Gets the size of the image. + /// + /// The path. + /// ImageSize. + ImageSize GetImageSize(string path); + /// /// Adds the parts. /// -- cgit v1.2.3