diff --git a/Emby.Drawing/Emby.Drawing.csproj b/Emby.Drawing/Emby.Drawing.csproj
index 45ac97ecc4..06e042d74e 100644
--- a/Emby.Drawing/Emby.Drawing.csproj
+++ b/Emby.Drawing/Emby.Drawing.csproj
@@ -37,7 +37,7 @@
False
- ..\packages\ImageMagickSharp.1.0.0.17\lib\net45\ImageMagickSharp.dll
+ ..\packages\ImageMagickSharp.1.0.0.18\lib\net45\ImageMagickSharp.dll
..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll
diff --git a/Emby.Drawing/GDI/GDIImageEncoder.cs b/Emby.Drawing/GDI/GDIImageEncoder.cs
index 51b4605c33..bdd1c5a22f 100644
--- a/Emby.Drawing/GDI/GDIImageEncoder.cs
+++ b/Emby.Drawing/GDI/GDIImageEncoder.cs
@@ -89,7 +89,7 @@ namespace Emby.Drawing.GDI
}
}
- public void EncodeImage(string inputPath, string cacheFilePath, int rotationAngle, int width, int height, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
+ 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;
diff --git a/Emby.Drawing/IImageEncoder.cs b/Emby.Drawing/IImageEncoder.cs
index f36498be76..73b5398993 100644
--- a/Emby.Drawing/IImageEncoder.cs
+++ b/Emby.Drawing/IImageEncoder.cs
@@ -27,13 +27,13 @@ namespace Emby.Drawing
///
/// The input path.
/// The output path.
- /// The rotation angle.
+ /// if set to true [automatic orient].
/// The width.
/// The height.
/// The quality.
/// The options.
/// The output format.
- void EncodeImage(string inputPath, string outputPath, int rotationAngle, int width, int height, int quality, ImageProcessingOptions options, ImageFormat outputFormat);
+ void EncodeImage(string inputPath, string outputPath, bool autoOrient, int width, int height, int quality, ImageProcessingOptions options, ImageFormat outputFormat);
///
/// Creates the image collage.
diff --git a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
index fd9ed5f1e5..b8300ac979 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))
diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs
index 9de6d20427..e016127004 100644
--- a/Emby.Drawing/ImageProcessor.cs
+++ b/Emby.Drawing/ImageProcessor.cs
@@ -257,7 +257,7 @@ namespace Emby.Drawing
imageProcessingLockTaken = true;
- _imageEncoder.EncodeImage(originalImagePath, cacheFilePath, GetRotationAngle(options.Item), newWidth, newHeight, quality, options, outputFormat);
+ _imageEncoder.EncodeImage(originalImagePath, cacheFilePath, AutoOrient(options.Item), newWidth, newHeight, quality, options, outputFormat);
}
return new Tuple(cacheFilePath, GetMimeType(outputFormat, cacheFilePath));
@@ -281,35 +281,32 @@ namespace Emby.Drawing
}
}
- private int GetRotationAngle(IHasImages item)
+ private bool AutoOrient(IHasImages item)
{
var photo = item as Photo;
if (photo != null && photo.Orientation.HasValue)
{
- switch (photo.Orientation.Value)
- {
- case ImageOrientation.TopLeft:
- return 0;
- case ImageOrientation.TopRight:
- return 0;
- case ImageOrientation.BottomLeft:
- return 270;
- case ImageOrientation.BottomRight:
- return 180;
- case ImageOrientation.LeftBottom:
- return -90;
- case ImageOrientation.LeftTop:
- return 0;
- case ImageOrientation.RightBottom:
- return 0;
- case ImageOrientation.RightTop:
- return 90;
- }
+ return true;
}
- return 0;
+ return false;
}
+ //private static int[][] OPERATIONS = new int[][] {
+ // TopLeft
+ //new int[] { 0, NONE},
+ // TopRight
+ //new int[] { 0, HORIZONTAL},
+ //new int[] {180, NONE},
+ // LeftTop
+ //new int[] { 0, VERTICAL},
+ //new int[] { 90, HORIZONTAL},
+ // RightTop
+ //new int[] { 90, NONE},
+ //new int[] {-90, HORIZONTAL},
+ //new int[] {-90, NONE},
+ //};
+
private string GetMimeType(ImageFormat format, string path)
{
if (format == ImageFormat.Bmp)
diff --git a/Emby.Drawing/NullImageEncoder.cs b/Emby.Drawing/NullImageEncoder.cs
index 032335a460..4fa18ce553 100644
--- a/Emby.Drawing/NullImageEncoder.cs
+++ b/Emby.Drawing/NullImageEncoder.cs
@@ -32,7 +32,7 @@ namespace Emby.Drawing
throw new NotImplementedException();
}
- 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)
{
throw new NotImplementedException();
}
diff --git a/Emby.Drawing/packages.config b/Emby.Drawing/packages.config
index 51731c4748..62a241f1fc 100644
--- a/Emby.Drawing/packages.config
+++ b/Emby.Drawing/packages.config
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index 3e62f47351..c629831923 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -67,7 +67,7 @@
False
- ..\packages\ImageMagickSharp.1.0.0.17\lib\net45\ImageMagickSharp.dll
+ ..\packages\ImageMagickSharp.1.0.0.18\lib\net45\ImageMagickSharp.dll
..\packages\MediaBrowser.IsoMounting.3.0.69\lib\net45\MediaBrowser.IsoMounter.dll
diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config
index db2bb54761..be12bcd5c3 100644
--- a/MediaBrowser.ServerApplication/packages.config
+++ b/MediaBrowser.ServerApplication/packages.config
@@ -1,7 +1,7 @@
-
+