aboutsummaryrefslogtreecommitdiff
path: root/Emby.Drawing.Net
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-05-10 15:15:14 -0400
committerGitHub <noreply@github.com>2017-05-10 15:15:14 -0400
commit6ee9da3717a563d110fc56c93478885d19449cce (patch)
treef353dec0ac06811918b33f6deed4e7fbe3c27935 /Emby.Drawing.Net
parent06a1393abed20137844f062e44cf8ae7feb9e8f6 (diff)
parentb9baf377e81e454438d9faad1b1b793a719bb667 (diff)
Merge pull request #2628 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Drawing.Net')
-rw-r--r--Emby.Drawing.Net/GDIImageEncoder.cs17
1 files changed, 7 insertions, 10 deletions
diff --git a/Emby.Drawing.Net/GDIImageEncoder.cs b/Emby.Drawing.Net/GDIImageEncoder.cs
index 638415afd..e710baaa7 100644
--- a/Emby.Drawing.Net/GDIImageEncoder.cs
+++ b/Emby.Drawing.Net/GDIImageEncoder.cs
@@ -75,27 +75,24 @@ namespace Emby.Drawing.Net
}
}
- public void CropWhiteSpace(string inputPath, string outputPath)
+ private Image GetImage(string path, bool cropWhitespace)
{
- using (var image = (Bitmap)Image.FromFile(inputPath))
+ if (cropWhitespace)
{
- using (var croppedImage = image.CropWhitespace())
+ using (var originalImage = (Bitmap)Image.FromFile(path))
{
- _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(outputPath));
-
- using (var outputStream = _fileSystem.GetFileStream(outputPath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, false))
- {
- croppedImage.Save(System.Drawing.Imaging.ImageFormat.Png, outputStream, 100);
- }
+ return originalImage.CropWhitespace();
}
}
+
+ return Image.FromFile(path);
}
public void EncodeImage(string inputPath, string cacheFilePath, bool autoOrient, int width, int height, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
{
var hasPostProcessing = !string.IsNullOrEmpty(options.BackgroundColor) || options.UnplayedCount.HasValue || options.AddPlayedIndicator || options.PercentPlayed > 0;
- using (var originalImage = Image.FromFile(inputPath))
+ using (var originalImage = GetImage(inputPath, options.CropWhiteSpace))
{
var newWidth = Convert.ToInt32(width);
var newHeight = Convert.ToInt32(height);