aboutsummaryrefslogtreecommitdiff
path: root/Emby.Drawing/ImageProcessor.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-05-12 01:09:16 -0400
committerGitHub <noreply@github.com>2017-05-12 01:09:16 -0400
commit275fe6622056d134fdf4737319507c4c51d3f389 (patch)
tree5fb9b96bf0aa3be26dec14313057383af71d5824 /Emby.Drawing/ImageProcessor.cs
parente06563831e0f7a5e9a6120ab16decb05a0cde8f7 (diff)
parent911de889b1e941c29ee0d7ff68d728fc009b745f (diff)
Merge pull request #2630 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Drawing/ImageProcessor.cs')
-rw-r--r--Emby.Drawing/ImageProcessor.cs49
1 files changed, 31 insertions, 18 deletions
diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs
index 9dc5f75ee2..030291def2 100644
--- a/Emby.Drawing/ImageProcessor.cs
+++ b/Emby.Drawing/ImageProcessor.cs
@@ -198,7 +198,7 @@ namespace Emby.Drawing
return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
}
- ImageSize? originalImageSize;
+ ImageSize? originalImageSize = null;
try
{
originalImageSize = GetImageSize(originalImagePath, dateModified, true);
@@ -333,7 +333,7 @@ namespace Emby.Drawing
return new ImageSize(options.Width.Value, options.Height.Value);
}
- var aspect = GetEstimatedAspectRatio(options.Image.Type);
+ var aspect = GetEstimatedAspectRatio(options.Image.Type, options.Item);
var width = options.Width ?? options.MaxWidth;
@@ -348,7 +348,7 @@ namespace Emby.Drawing
return new ImageSize(widthValue, height);
}
- private double GetEstimatedAspectRatio(ImageType type)
+ private double GetEstimatedAspectRatio(ImageType type, IHasImages item)
{
switch (type)
{
@@ -368,7 +368,7 @@ namespace Emby.Drawing
case ImageType.Logo:
return 2.58;
case ImageType.Primary:
- return .667;
+ return item.GetDefaultPrimaryImageAspectRatio() ?? .667;
default:
return 1;
}
@@ -499,26 +499,39 @@ namespace Emby.Drawing
/// <returns>ImageSize.</returns>
private ImageSize GetImageSizeInternal(string path, bool allowSlowMethod)
{
+ // Can't use taglib because it keeps a lock on the file
+ //try
+ //{
+ // using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(path), _fileSystem.OpenRead(path), null)))
+ // {
+ // var image = file as TagLib.Image.File;
+
+ // var properties = image.Properties;
+
+ // return new ImageSize
+ // {
+ // Height = properties.PhotoHeight,
+ // Width = properties.PhotoWidth
+ // };
+ // }
+ //}
+ //catch
+ //{
+ //}
+
try
{
- using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(path), _fileSystem.OpenRead(path), null)))
- {
- var image = file as TagLib.Image.File;
-
- var properties = image.Properties;
-
- return new ImageSize
- {
- Height = properties.PhotoHeight,
- Width = properties.PhotoWidth
- };
- }
+ return ImageHeader.GetDimensions(path, _logger, _fileSystem);
}
catch
{
- }
+ if (allowSlowMethod)
+ {
+ return _imageEncoder.GetImageSize(path);
+ }
- return ImageHeader.GetDimensions(path, _logger, _fileSystem);
+ throw;
+ }
}
private readonly ITimer _saveImageSizeTimer;