aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcvium <clausvium@gmail.com>2021-11-10 23:29:41 +0100
committercvium <clausvium@gmail.com>2021-11-10 23:29:41 +0100
commit0415d1ccef19c48a2eaa3c545648ce657f95cfb8 (patch)
tree3433a44e2debb10bc65b914ba03597b3f992287a
parentd10de5b7f93511daa3cf239b4b4c34dc79000969 (diff)
Reduce indentation
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs31
1 files changed, 16 insertions, 15 deletions
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index 4193d0018..f23f4a13f 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -1406,28 +1406,29 @@ namespace Emby.Server.Implementations.Dto
var width = imageInfo.Width;
var height = imageInfo.Height;
+ if (width > 0 && height > 0)
+ {
+ return (double)width / height;
+ }
+
// Fallback to the image processor if the image info is somehow incorrect
- if (width <= 0 || height <= 0)
+ try
{
- try
- {
- var size = _imageProcessor.GetImageDimensions(item, imageInfo);
- width = size.Width;
- height = size.Height;
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Failed to determine primary image aspect ratio for {ImagePath}", imageInfo.Path);
- return item.GetDefaultPrimaryImageAspectRatio();
- }
+ var size = _imageProcessor.GetImageDimensions(item, imageInfo);
+ width = size.Width;
+ height = size.Height;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Failed to determine primary image aspect ratio for {ImagePath}", imageInfo.Path);
}
- if (width <= 0 || height <= 0)
+ if (width > 0 && height > 0)
{
- return item.GetDefaultPrimaryImageAspectRatio();
+ return (double)width / height;
}
- return (double)width / height;
+ return item.GetDefaultPrimaryImageAspectRatio();
}
}
}