diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 8db0609d9..4b4aeb83f 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -658,7 +658,20 @@ namespace MediaBrowser.Api.Images // See if we can avoid a file system lookup by looking for the file in ResolveArgs var originalFileImageDateModified = kernel.ImageManager.GetImageDateModified(item, request.Type, index); - var supportedImageEnhancers = kernel.ImageEnhancers.Where(i => i.Supports(item, request.Type)).ToList(); + var supportedImageEnhancers = kernel.ImageEnhancers.Where(i => + { + try + { + return i.Supports(item, request.Type); + } + catch (Exception ex) + { + Logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name); + + return false; + } + + }).ToList(); // If the file does not exist GetLastWriteTimeUtc will return jan 1, 1601 as opposed to throwing an exception // http://msdn.microsoft.com/en-us/library/system.io.file.getlastwritetimeutc.aspx diff --git a/MediaBrowser.Controller/Drawing/ImageManager.cs b/MediaBrowser.Controller/Drawing/ImageManager.cs index f891d5a18..f2d6657d5 100644 --- a/MediaBrowser.Controller/Drawing/ImageManager.cs +++ b/MediaBrowser.Controller/Drawing/ImageManager.cs @@ -531,8 +531,21 @@ namespace MediaBrowser.Controller.Drawing throw new ArgumentNullException("item"); } - var supportedEnhancers = _kernel.ImageEnhancers.Where(i => i.Supports(item, imageType)).ToList(); + var supportedEnhancers = _kernel.ImageEnhancers.Where(i => + { + try + { + return i.Supports(item, imageType); + } + catch (Exception ex) + { + _logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name); + return false; + } + + }).ToList(); + // No enhancement - don't cache if (supportedEnhancers.Count == 0) { @@ -609,7 +622,20 @@ namespace MediaBrowser.Controller.Drawing var dateModified = GetImageDateModified(item, imagePath); - var supportedEnhancers = _kernel.ImageEnhancers.Where(i => i.Supports(item, imageType)); + var supportedEnhancers = _kernel.ImageEnhancers.Where(i => + { + try + { + return i.Supports(item, imageType); + } + catch (Exception ex) + { + _logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name); + + return false; + } + + }).ToList(); return GetImageCacheTag(imagePath, dateModified, supportedEnhancers, item, imageType); } diff --git a/MediaBrowser.Controller/Dto/DtoBuilder.cs b/MediaBrowser.Controller/Dto/DtoBuilder.cs index 558c19049..549248595 100644 --- a/MediaBrowser.Controller/Dto/DtoBuilder.cs +++ b/MediaBrowser.Controller/Dto/DtoBuilder.cs @@ -182,11 +182,32 @@ namespace MediaBrowser.Controller.Dto return; } - foreach (var enhancer in Kernel.Instance.ImageEnhancers - .Where(i => i.Supports(item, ImageType.Primary))) + var supportedEnhancers = Kernel.Instance.ImageEnhancers.Where(i => { + try + { + return i.Supports(item, ImageType.Primary); + } + catch (Exception ex) + { + logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name); - size = enhancer.GetEnhancedImageSize(item, ImageType.Primary, 0, size); + return false; + } + + }).ToList(); + + + foreach (var enhancer in supportedEnhancers) + { + try + { + size = enhancer.GetEnhancedImageSize(item, ImageType.Primary, 0, size); + } + catch (Exception ex) + { + logger.ErrorException("Error in image enhancer: {0}", ex, enhancer.GetType().Name); + } } dto.PrimaryImageAspectRatio = size.Width / size.Height;