From f98b619b643a9af7b892ce8a591972fac5bb21d4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 18 Jun 2014 11:12:20 -0400 Subject: fix language selections --- .../Drawing/ImageProcessor.cs | 53 +++++++++++++--------- 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs') diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs index 38f812809..86bd6b731 100644 --- a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs +++ b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs @@ -128,7 +128,7 @@ namespace MediaBrowser.Server.Implementations.Drawing throw new ArgumentNullException("toStream"); } - var originalImagePath = options.OriginalImagePath; + var originalImagePath = options.Image.Path; if (options.HasDefaultOptions() && options.Enhancers.Count == 0 && !options.CropWhiteSpace) { @@ -140,7 +140,7 @@ namespace MediaBrowser.Server.Implementations.Drawing } } - var dateModified = options.OriginalImageDateModified; + var dateModified = options.Image.DateModified; if (options.CropWhiteSpace) { @@ -152,7 +152,7 @@ namespace MediaBrowser.Server.Implementations.Drawing if (options.Enhancers.Count > 0) { - var tuple = await GetEnhancedImage(originalImagePath, dateModified, options.Item, options.ImageType, options.ImageIndex, options.Enhancers).ConfigureAwait(false); + var tuple = await GetEnhancedImage(options.Image, options.Item, options.ImageIndex, options.Enhancers).ConfigureAwait(false); originalImagePath = tuple.Item1; dateModified = tuple.Item2; @@ -663,20 +663,18 @@ namespace MediaBrowser.Server.Implementations.Drawing var supportedEnhancers = GetSupportedEnhancers(item, image.Type); - return GetImageCacheTag(item, image.Type, image.Path, image.DateModified, supportedEnhancers.ToList()); + return GetImageCacheTag(item, image, supportedEnhancers.ToList()); } /// /// Gets the image cache tag. /// /// The item. - /// Type of the image. - /// The original image path. - /// The date modified of the original image file. + /// The image. /// The image enhancers. /// Guid. /// item - public string GetImageCacheTag(IHasImages item, ImageType imageType, string originalImagePath, DateTime dateModified, List imageEnhancers) + public string GetImageCacheTag(IHasImages item, ItemImageInfo image, List imageEnhancers) { if (item == null) { @@ -688,11 +686,15 @@ namespace MediaBrowser.Server.Implementations.Drawing throw new ArgumentNullException("imageEnhancers"); } - if (string.IsNullOrEmpty(originalImagePath)) + if (image == null) { - throw new ArgumentNullException("originalImagePath"); + throw new ArgumentNullException("image"); } + var originalImagePath = image.Path; + var dateModified = image.DateModified; + var imageType = image.Type; + // Optimization if (imageEnhancers.Count == 0) { @@ -718,23 +720,27 @@ namespace MediaBrowser.Server.Implementations.Drawing var enhancers = GetSupportedEnhancers(item, imageType).ToList(); var imageInfo = item.GetImageInfo(imageType, imageIndex); - var imagePath = imageInfo.Path; - - var dateModified = imageInfo.DateModified; - var result = await GetEnhancedImage(imagePath, dateModified, item, imageType, imageIndex, enhancers); + var result = await GetEnhancedImage(imageInfo, item, imageIndex, enhancers); return result.Item1; } - private async Task> GetEnhancedImage(string originalImagePath, DateTime dateModified, IHasImages item, - ImageType imageType, int imageIndex, - List enhancers) + private async Task> GetEnhancedImage(ItemImageInfo image, + IHasImages item, + int imageIndex, + List enhancers) { + var originalImagePath = image.Path; + var dateModified = image.DateModified; + var imageType = image.Type; + try { + var cacheGuid = GetImageCacheTag(item, image, enhancers); + // Enhance if we have enhancers - var ehnancedImagePath = await GetEnhancedImageInternal(originalImagePath, dateModified, item, imageType, imageIndex, enhancers).ConfigureAwait(false); + var ehnancedImagePath = await GetEnhancedImageInternal(originalImagePath, item, imageType, imageIndex, enhancers, cacheGuid).ConfigureAwait(false); // If the path changed update dateModified if (!ehnancedImagePath.Equals(originalImagePath, StringComparison.OrdinalIgnoreCase)) @@ -756,14 +762,19 @@ namespace MediaBrowser.Server.Implementations.Drawing /// Runs an image through the image enhancers, caches the result, and returns the cached path /// /// The original image path. - /// The date modified of the original image file. /// The item. /// Type of the image. /// Index of the image. /// The supported enhancers. + /// The cache unique identifier. /// System.String. /// originalImagePath - private async Task GetEnhancedImageInternal(string originalImagePath, DateTime dateModified, IHasImages item, ImageType imageType, int imageIndex, List supportedEnhancers) + private async Task GetEnhancedImageInternal(string originalImagePath, + IHasImages item, + ImageType imageType, + int imageIndex, + IEnumerable supportedEnhancers, + string cacheGuid) { if (string.IsNullOrEmpty(originalImagePath)) { @@ -775,8 +786,6 @@ namespace MediaBrowser.Server.Implementations.Drawing throw new ArgumentNullException("item"); } - var cacheGuid = GetImageCacheTag(item, imageType, originalImagePath, dateModified, supportedEnhancers); - // All enhanced images are saved as png to allow transparency var enhancedImagePath = GetCachePath(EnhancedImageCachePath, cacheGuid + ".png"); -- cgit v1.2.3