diff options
| -rw-r--r-- | MediaBrowser.Controller/Drawing/ImageExtensions.cs | 16 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/MediaBrowser.Controller/Drawing/ImageExtensions.cs b/MediaBrowser.Controller/Drawing/ImageExtensions.cs index a7dbc701f..8e75c5210 100644 --- a/MediaBrowser.Controller/Drawing/ImageExtensions.cs +++ b/MediaBrowser.Controller/Drawing/ImageExtensions.cs @@ -170,7 +170,7 @@ namespace MediaBrowser.Controller.Drawing var thumbnail = new Bitmap(croppedWidth, croppedHeight, PixelFormat.Format32bppPArgb); // Preserve the original resolution - thumbnail.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution); + TrySetResolution(thumbnail, bmp.HorizontalResolution, bmp.VerticalResolution); using (var thumbnailGraph = Graphics.FromImage(thumbnail)) { @@ -189,6 +189,20 @@ namespace MediaBrowser.Controller.Drawing } /// <summary> + /// Tries the set resolution. + /// </summary> + /// <param name="bmp">The BMP.</param> + /// <param name="x">The x.</param> + /// <param name="y">The y.</param> + private static void TrySetResolution(Bitmap bmp, float x, float y) + { + if (x > 0 && y > 0) + { + bmp.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution); + } + } + + /// <summary> /// Determines whether or not a row of pixels is all whitespace /// </summary> /// <param name="bmp">The BMP.</param> diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs index d75f2647c..6378cef52 100644 --- a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs +++ b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs @@ -229,7 +229,7 @@ namespace MediaBrowser.Server.Implementations.Drawing using (var thumbnail = new Bitmap(newWidth, newHeight, PixelFormat.Format32bppPArgb)) { // Mono throw an exeception if assign 0 to SetResolution - if (originalImage.HorizontalResolution >= 0 && originalImage.VerticalResolution >= 0) + if (originalImage.HorizontalResolution > 0 && originalImage.VerticalResolution > 0) { // Preserve the original resolution thumbnail.SetResolution(originalImage.HorizontalResolution, originalImage.VerticalResolution); |
