diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-06-09 15:24:31 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-06-09 15:24:31 -0400 |
| commit | d76bcd8473c7a0d554168ea5b05554e2a7e560f7 (patch) | |
| tree | d82fca3610657edb2df085467be5b8bff2e7d7f4 /Emby.Drawing/ImageProcessor.cs | |
| parent | e2ec83cbaae3d2d711126a2c29b3f112c613dda4 (diff) | |
fix photo orientation
Diffstat (limited to 'Emby.Drawing/ImageProcessor.cs')
| -rw-r--r-- | Emby.Drawing/ImageProcessor.cs | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index a1543382f..eb5e0d82a 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -217,14 +217,23 @@ namespace Emby.Drawing dateModified = tuple.Item2; } - if (options.HasDefaultOptions(originalImagePath)) + var photo = item as Photo; + var autoOrient = false; + ImageOrientation? orientation = null; + if (photo != null && photo.Orientation.HasValue && photo.Orientation.Value != ImageOrientation.TopLeft) + { + autoOrient = true; + orientation = photo.Orientation; + } + + if (options.HasDefaultOptions(originalImagePath) && !autoOrient) { // Just spit out the original file if all the options are default return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified); } ImageSize? originalImageSize = GetSavedImageSize(originalImagePath, dateModified); - if (originalImageSize.HasValue && options.HasDefaultOptions(originalImagePath, originalImageSize.Value)) + if (originalImageSize.HasValue && options.HasDefaultOptions(originalImagePath, originalImageSize.Value) && !autoOrient) { // Just spit out the original file if all the options are default _logger.Info("Returning original image {0}", originalImagePath); @@ -243,7 +252,6 @@ namespace Emby.Drawing if (!_fileSystem.FileExists(cacheFilePath)) { - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFilePath)); var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(cacheFilePath)); _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(tmpPath)); @@ -252,13 +260,14 @@ namespace Emby.Drawing item = _libraryManager().GetItemById(options.ItemId); } - var resultPath =_imageEncoder.EncodeImage(originalImagePath, dateModified, tmpPath, AutoOrient(item), quality, options, outputFormat); + var resultPath = _imageEncoder.EncodeImage(originalImagePath, dateModified, tmpPath, autoOrient, orientation, quality, options, outputFormat); if (string.Equals(resultPath, originalImagePath, StringComparison.OrdinalIgnoreCase)) { return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified); } + _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFilePath)); CopyFile(tmpPath, cacheFilePath); return new Tuple<string, string, DateTime>(tmpPath, GetMimeType(outputFormat, cacheFilePath), _fileSystem.GetLastWriteTimeUtc(tmpPath)); @@ -288,17 +297,6 @@ namespace Emby.Drawing } } - private bool AutoOrient(IHasImages item) - { - var photo = item as Photo; - if (photo != null && photo.Orientation.HasValue) - { - return true; - } - - return false; - } - //private static int[][] OPERATIONS = new int[][] { // TopLeft //new int[] { 0, NONE}, |
