From 799494af0b4c5ff380eeb873ff727ee179c97193 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 19 May 2017 13:09:37 -0400 Subject: [PATCH] update image methods --- Emby.Drawing/ImageProcessor.cs | 4 +-- .../Collections/CollectionImageProvider.cs | 2 +- .../Images/BaseDynamicImageProvider.cs | 26 +++++++++---------- .../Photos/PhotoAlbumImageProvider.cs | 2 +- .../CollectionFolderImageProvider.cs | 12 ++++----- .../UserViews/DynamicImageProvider.cs | 4 +-- .../Drawing/IImageProcessor.cs | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 89bc96be5..92382aa47 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -670,7 +670,7 @@ namespace Emby.Drawing var ehnancedImagePath = await GetEnhancedImageInternal(originalImagePath, item, imageType, imageIndex, enhancers, cacheGuid).ConfigureAwait(false); // If the path changed update dateModified - if (!ehnancedImagePath.Equals(originalImagePath, StringComparison.OrdinalIgnoreCase)) + if (!string.Equals(ehnancedImagePath, originalImagePath, StringComparison.OrdinalIgnoreCase)) { return GetResult(ehnancedImagePath); } @@ -829,7 +829,7 @@ namespace Emby.Drawing return Path.Combine(path, filename); } - public async Task CreateImageCollage(ImageCollageOptions options) + public void CreateImageCollage(ImageCollageOptions options) { _logger.Info("Creating image collage and saving to {0}", options.OutputPath); diff --git a/Emby.Server.Implementations/Collections/CollectionImageProvider.cs b/Emby.Server.Implementations/Collections/CollectionImageProvider.cs index b82d4e44e..aafb13329 100644 --- a/Emby.Server.Implementations/Collections/CollectionImageProvider.cs +++ b/Emby.Server.Implementations/Collections/CollectionImageProvider.cs @@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Collections return Task.FromResult(GetFinalItems(items, 2)); } - protected override Task CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) + protected string CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) { return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary); } diff --git a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs index b2ec84a82..19681a832 100644 --- a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs +++ b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs @@ -140,7 +140,7 @@ namespace Emby.Server.Implementations.Images { var outputPathWithoutExtension = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid().ToString("N")); FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPathWithoutExtension)); - string outputPath = await CreateImage(item, itemsWithImages, outputPathWithoutExtension, imageType, 0).ConfigureAwait(false); + string outputPath = CreateImage(item, itemsWithImages, outputPathWithoutExtension, imageType, 0); if (string.IsNullOrWhiteSpace(outputPath)) { @@ -161,7 +161,7 @@ namespace Emby.Server.Implementations.Images protected abstract Task> GetItemsWithImages(IHasImages item); - protected Task CreateThumbCollage(IHasImages primaryItem, List items, string outputPath) + protected string CreateThumbCollage(IHasImages primaryItem, List items, string outputPath) { return CreateCollage(primaryItem, items, outputPath, 640, 360); } @@ -188,22 +188,22 @@ namespace Emby.Server.Implementations.Images .Where(i => !string.IsNullOrWhiteSpace(i)); } - protected Task CreatePosterCollage(IHasImages primaryItem, List items, string outputPath) + protected string CreatePosterCollage(IHasImages primaryItem, List items, string outputPath) { return CreateCollage(primaryItem, items, outputPath, 400, 600); } - protected Task CreateSquareCollage(IHasImages primaryItem, List items, string outputPath) + protected string CreateSquareCollage(IHasImages primaryItem, List items, string outputPath) { return CreateCollage(primaryItem, items, outputPath, 600, 600); } - protected Task CreateThumbCollage(IHasImages primaryItem, List items, string outputPath, int width, int height) + protected string CreateThumbCollage(IHasImages primaryItem, List items, string outputPath, int width, int height) { return CreateCollage(primaryItem, items, outputPath, width, height); } - private async Task CreateCollage(IHasImages primaryItem, List items, string outputPath, int width, int height) + private string CreateCollage(IHasImages primaryItem, List items, string outputPath, int width, int height) { FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPath)); @@ -225,7 +225,7 @@ namespace Emby.Server.Implementations.Images return null; } - await ImageProcessor.CreateImageCollage(options).ConfigureAwait(false); + ImageProcessor.CreateImageCollage(options); return outputPath; } @@ -234,7 +234,7 @@ namespace Emby.Server.Implementations.Images get { return "Dynamic Image Provider"; } } - protected virtual async Task CreateImage(IHasImages item, + protected virtual string CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, @@ -249,20 +249,20 @@ namespace Emby.Server.Implementations.Images if (imageType == ImageType.Thumb) { - return await CreateThumbCollage(item, itemsWithImages, outputPath).ConfigureAwait(false); + return CreateThumbCollage(item, itemsWithImages, outputPath); } if (imageType == ImageType.Primary) { if (item is UserView) { - return await CreateSquareCollage(item, itemsWithImages, outputPath).ConfigureAwait(false); + return CreateSquareCollage(item, itemsWithImages, outputPath); } if (item is Playlist || item is MusicGenre || item is Genre || item is GameGenre || item is PhotoAlbum) { - return await CreateSquareCollage(item, itemsWithImages, outputPath).ConfigureAwait(false); + return CreateSquareCollage(item, itemsWithImages, outputPath); } - return await CreatePosterCollage(item, itemsWithImages, outputPath).ConfigureAwait(false); + return CreatePosterCollage(item, itemsWithImages, outputPath); } throw new ArgumentException("Unexpected image type"); @@ -346,7 +346,7 @@ namespace Emby.Server.Implementations.Images } } - protected async Task CreateSingleImage(List itemsWithImages, string outputPathWithoutExtension, ImageType imageType) + protected string CreateSingleImage(List itemsWithImages, string outputPathWithoutExtension, ImageType imageType) { var image = itemsWithImages .Where(i => i.HasImage(imageType) && i.GetImageInfo(imageType, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(imageType))) diff --git a/Emby.Server.Implementations/Photos/PhotoAlbumImageProvider.cs b/Emby.Server.Implementations/Photos/PhotoAlbumImageProvider.cs index cc1756f96..c425a761a 100644 --- a/Emby.Server.Implementations/Photos/PhotoAlbumImageProvider.cs +++ b/Emby.Server.Implementations/Photos/PhotoAlbumImageProvider.cs @@ -26,7 +26,7 @@ namespace Emby.Server.Implementations.Photos return Task.FromResult(items); } - protected override Task CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) + protected string CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) { return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary); } diff --git a/Emby.Server.Implementations/UserViews/CollectionFolderImageProvider.cs b/Emby.Server.Implementations/UserViews/CollectionFolderImageProvider.cs index ab6307238..7d3a118c0 100644 --- a/Emby.Server.Implementations/UserViews/CollectionFolderImageProvider.cs +++ b/Emby.Server.Implementations/UserViews/CollectionFolderImageProvider.cs @@ -98,7 +98,7 @@ namespace Emby.Server.Implementations.UserViews return item is CollectionFolder; } - protected override async Task CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) + protected override string CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) { var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png"); @@ -109,10 +109,10 @@ namespace Emby.Server.Implementations.UserViews return null; } - return await CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540).ConfigureAwait(false); + return CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540); } - return await base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex).ConfigureAwait(false); + return base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex); } } @@ -155,7 +155,7 @@ namespace Emby.Server.Implementations.UserViews return item is ManualCollectionsFolder; } - protected override async Task CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) + protected override string CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) { var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png"); @@ -166,10 +166,10 @@ namespace Emby.Server.Implementations.UserViews return null; } - return await CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540).ConfigureAwait(false); + return CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540); } - return await base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex).ConfigureAwait(false); + return base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex); } } diff --git a/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs b/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs index b8d03db3d..b0fb954e2 100644 --- a/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs +++ b/Emby.Server.Implementations/UserViews/DynamicImageProvider.cs @@ -159,7 +159,7 @@ namespace Emby.Server.Implementations.UserViews return collectionStripViewTypes.Contains(view.ViewType ?? string.Empty); } - protected override async Task CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) + protected override string CreateImage(IHasImages item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) { if (itemsWithImages.Count == 0) { @@ -168,7 +168,7 @@ namespace Emby.Server.Implementations.UserViews var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png"); - return await CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540).ConfigureAwait(false); + return CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540); } } } diff --git a/MediaBrowser.Controller/Drawing/IImageProcessor.cs b/MediaBrowser.Controller/Drawing/IImageProcessor.cs index 7d84719ab..d98638d55 100644 --- a/MediaBrowser.Controller/Drawing/IImageProcessor.cs +++ b/MediaBrowser.Controller/Drawing/IImageProcessor.cs @@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Drawing /// Creates the image collage. /// /// The options. - Task CreateImageCollage(ImageCollageOptions options); + void CreateImageCollage(ImageCollageOptions options); /// /// Gets a value indicating whether [supports image collage creation].