fix image resizing

This commit is contained in:
Luke Pulverenti 2017-05-10 22:57:25 -04:00
parent aae64e6b87
commit 0f198dc818

View file

@ -225,8 +225,8 @@ namespace Emby.Drawing
if (!_fileSystem.FileExists(cacheFilePath)) if (!_fileSystem.FileExists(cacheFilePath))
{ {
var newWidth = Convert.ToInt32(newSize.Width); var newWidth = Convert.ToInt32(Math.Round(newSize.Width));
var newHeight = Convert.ToInt32(newSize.Height); var newHeight = Convert.ToInt32(Math.Round(newSize.Height));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFilePath)); _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFilePath));
var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(cacheFilePath)); var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(cacheFilePath));
@ -339,13 +339,13 @@ namespace Emby.Drawing
if (width.HasValue) if (width.HasValue)
{ {
var heightValue = aspect / width.Value; var heightValue = width.Value / aspect;
return new ImageSize(width.Value, Convert.ToInt32(heightValue)); return new ImageSize(width.Value, heightValue);
} }
var height = options.Height ?? options.MaxHeight ?? 200; var height = options.Height ?? options.MaxHeight ?? 200;
var widthValue = aspect * height; var widthValue = aspect * height;
return new ImageSize(Convert.ToInt32(widthValue), height); return new ImageSize(widthValue, height);
} }
private double GetEstimatedAspectRatio(ImageType type) private double GetEstimatedAspectRatio(ImageType type)