aboutsummaryrefslogtreecommitdiff
path: root/Emby.Drawing
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Drawing')
-rw-r--r--Emby.Drawing/Emby.Drawing.csproj2
-rw-r--r--Emby.Drawing/ImageMagick/ImageMagickEncoder.cs26
-rw-r--r--Emby.Drawing/ImageProcessor.cs2
-rw-r--r--Emby.Drawing/packages.config2
4 files changed, 26 insertions, 6 deletions
diff --git a/Emby.Drawing/Emby.Drawing.csproj b/Emby.Drawing/Emby.Drawing.csproj
index e9911a12d..6cda8b5d0 100644
--- a/Emby.Drawing/Emby.Drawing.csproj
+++ b/Emby.Drawing/Emby.Drawing.csproj
@@ -37,7 +37,7 @@
</Reference>
<Reference Include="ImageMagickSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\ImageMagickSharp.1.0.0.16\lib\net45\ImageMagickSharp.dll</HintPath>
+ <HintPath>..\packages\ImageMagickSharp.1.0.0.17\lib\net45\ImageMagickSharp.dll</HintPath>
</Reference>
<Reference Include="Patterns.Logging">
<HintPath>..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll</HintPath>
diff --git a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
index ed0760ee3..d097c8da3 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();
}
@@ -133,15 +136,19 @@ namespace Emby.Drawing.ImageMagick
public void EncodeImage(string inputPath, string outputPath, int width, int height, int quality, ImageProcessingOptions options)
{
+ // Even if the caller specified 100, don't use it because it takes forever
+ quality = Math.Min(quality, 99);
+
if (string.IsNullOrWhiteSpace(options.BackgroundColor) || !HasTransparency(inputPath))
{
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 +159,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 +174,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>
diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs
index ec5d66cba..a24987c05 100644
--- a/Emby.Drawing/ImageProcessor.cs
+++ b/Emby.Drawing/ImageProcessor.cs
@@ -224,7 +224,7 @@ namespace Emby.Drawing
return originalImagePath;
}
- var quality = options.Quality ?? 90;
+ var quality = options.Quality;
var outputFormat = GetOutputFormat(options.OutputFormat);
var cacheFilePath = GetCacheFilePath(originalImagePath, newSize, quality, dateModified, outputFormat, options.AddPlayedIndicator, options.PercentPlayed, options.UnplayedCount, options.BackgroundColor);
diff --git a/Emby.Drawing/packages.config b/Emby.Drawing/packages.config
index 0fcdc278e..3b8dbcab7 100644
--- a/Emby.Drawing/packages.config
+++ b/Emby.Drawing/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommonIO" version="1.0.0.5" targetFramework="net45" />
- <package id="ImageMagickSharp" version="1.0.0.16" targetFramework="net45" />
+ <package id="ImageMagickSharp" version="1.0.0.17" targetFramework="net45" />
<package id="Patterns.Logging" version="1.0.0.2" targetFramework="net45" />
</packages> \ No newline at end of file