diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-01-21 11:53:03 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-01-21 11:53:03 -0500 |
| commit | f380ddc5589e35da966833d3b8a6f073f369b38b (patch) | |
| tree | 3b068f73e7a6c12ef1bc7f77b86adf7deb245bc9 /Emby.Drawing/ImageMagick/ImageMagickEncoder.cs | |
| parent | faa9127a2081f40433b54795422dad10bb1bba9c (diff) | |
use image magick for auto-orientation
Diffstat (limited to 'Emby.Drawing/ImageMagick/ImageMagickEncoder.cs')
| -rw-r--r-- | Emby.Drawing/ImageMagick/ImageMagickEncoder.cs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs index fd9ed5f1e..b8300ac97 100644 --- a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs +++ b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs @@ -139,7 +139,7 @@ namespace Emby.Drawing.ImageMagick string.Equals(ext, ".webp", StringComparison.OrdinalIgnoreCase); } - public void EncodeImage(string inputPath, string outputPath, int rotationAngle, int width, int height, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat) + public void EncodeImage(string inputPath, string outputPath, bool autoOrient, int width, int height, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat) { // Even if the caller specified 100, don't use it because it takes forever quality = Math.Min(quality, 99); @@ -150,9 +150,9 @@ namespace Emby.Drawing.ImageMagick { ScaleImage(originalImage, width, height); - if (rotationAngle > 0) + if (autoOrient) { - RotateImage(originalImage, rotationAngle); + AutoOrientImage(originalImage); } DrawIndicator(originalImage, width, height, options); @@ -171,9 +171,9 @@ namespace Emby.Drawing.ImageMagick { ScaleImage(originalImage, width, height); - if (rotationAngle > 0) + if (autoOrient) { - RotateImage(originalImage, rotationAngle); + AutoOrientImage(originalImage); } wand.CurrentImage.CompositeImage(originalImage, CompositeOperator.OverCompositeOp, 0, 0); @@ -189,6 +189,11 @@ namespace Emby.Drawing.ImageMagick SaveDelay(); } + private void AutoOrientImage(MagickWand wand) + { + wand.CurrentImage.AutoOrientImage(); + } + public static void RotateImage(MagickWand wand, float angle) { using (var pixelWand = new PixelWand("none", 1)) |
