diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-10-22 02:22:43 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-10-22 02:22:43 -0400 |
| commit | 7e5036a5875cb7f03ad728f970d66471ca30236b (patch) | |
| tree | 31bb5509c42e490e1359483b7f047f63499317d6 /Emby.Drawing/ImageProcessor.cs | |
| parent | 7e2c52936ff15c2569a5cb6b3c5351c16c4163ff (diff) | |
update image aspect ratio detection
Diffstat (limited to 'Emby.Drawing/ImageProcessor.cs')
| -rw-r--r-- | Emby.Drawing/ImageProcessor.cs | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 831454972..6bdb06c83 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -442,19 +442,39 @@ namespace Emby.Drawing return GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLower()); } - public ImageSize GetImageSize(ItemImageInfo info, bool allowSlowMethods) + public ImageSize GetImageSize(BaseItem item, ItemImageInfo info) { - return GetImageSize(info.Path, allowSlowMethods); + return GetImageSize(item, info, false, true); } - public ImageSize GetImageSize(ItemImageInfo info) + public ImageSize GetImageSize(BaseItem item, ItemImageInfo info, bool allowSlowMethods, bool updateItem) { - return GetImageSize(info.Path, false); - } + var width = info.Width; + var height = info.Height; - public ImageSize GetImageSize(string path) - { - return GetImageSize(path, false); + if (height > 0 && width > 0) + { + return new ImageSize + { + Width = width, + Height = height + }; + } + + var path = item.Path; + _logger.Info("Getting image size for item {0} {1}", item.GetType().Name, path); + + var size = GetImageSize(path, allowSlowMethods); + + info.Height = Convert.ToInt32(size.Height); + info.Width = Convert.ToInt32(size.Width); + + if (updateItem) + { + _libraryManager().UpdateImages(item); + } + + return size; } /// <summary> |
