aboutsummaryrefslogtreecommitdiff
path: root/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-10-28 00:06:13 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-10-28 00:06:13 -0400
commit818662e051a07b15a9ac15df177835d7e4ef236b (patch)
treeee150ffbc39dd2602d878ddf3cacf3acf8f213aa /Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
parented0e1399fc785a3d4b1a161a84d2fcc8fff1e576 (diff)
use ImageMagick scale method
Diffstat (limited to 'Emby.Drawing/ImageMagick/ImageMagickEncoder.cs')
-rw-r--r--Emby.Drawing/ImageMagick/ImageMagickEncoder.cs23
1 files changed, 20 insertions, 3 deletions
diff --git a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
index ed0760ee3..c5ba6d9c8 100644
--- a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
+++ b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
@@ -9,6 +9,7 @@ using System;
using System.IO;
using System.Linq;
using CommonIO;
+using MediaBrowser.Controller.Configuration;
namespace Emby.Drawing.ImageMagick
{
@@ -18,13 +19,15 @@ namespace Emby.Drawing.ImageMagick
private readonly IApplicationPaths _appPaths;
private readonly IHttpClient _httpClient;
private readonly IFileSystem _fileSystem;
+ private readonly IServerConfigurationManager _config;
- public ImageMagickEncoder(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IFileSystem fileSystem)
+ public ImageMagickEncoder(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IFileSystem fileSystem, IServerConfigurationManager config)
{
_logger = logger;
_appPaths = appPaths;
_httpClient = httpClient;
_fileSystem = fileSystem;
+ _config = config;
LogVersion();
}
@@ -137,11 +140,12 @@ namespace Emby.Drawing.ImageMagick
{
using (var originalImage = new MagickWand(inputPath))
{
- originalImage.CurrentImage.ResizeImage(width, height);
+ ScaleImage(originalImage, width, height);
DrawIndicator(originalImage, width, height, options);
originalImage.CurrentImage.CompressionQuality = quality;
+ originalImage.CurrentImage.StripImage();
originalImage.SaveImage(outputPath);
}
@@ -152,12 +156,13 @@ namespace Emby.Drawing.ImageMagick
{
using (var originalImage = new MagickWand(inputPath))
{
- originalImage.CurrentImage.ResizeImage(width, height);
+ ScaleImage(originalImage, width, height);
wand.CurrentImage.CompositeImage(originalImage, CompositeOperator.OverCompositeOp, 0, 0);
DrawIndicator(wand, width, height, options);
wand.CurrentImage.CompressionQuality = quality;
+ wand.CurrentImage.StripImage();
wand.SaveImage(outputPath);
}
@@ -166,6 +171,18 @@ namespace Emby.Drawing.ImageMagick
SaveDelay();
}
+ private void ScaleImage(MagickWand wand, int width, int height)
+ {
+ if (_config.Configuration.EnableHighQualityImageScaling)
+ {
+ wand.CurrentImage.ResizeImage(width, height);
+ }
+ else
+ {
+ wand.CurrentImage.ScaleImage(width, height);
+ }
+ }
+
/// <summary>
/// Draws the indicator.
/// </summary>