diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-09-20 13:22:34 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-09-20 13:22:34 -0400 |
| commit | e8010955dc10c4be9b73c9a10de84356744b1cca (patch) | |
| tree | a9ef54677aa26a88e1134abfe6f799a778824f8d /Emby.Drawing/ImageProcessor.cs | |
| parent | 6d3dcd826695973fd958c92a775416a2e7b65835 (diff) | |
fix merge conflicts
Diffstat (limited to 'Emby.Drawing/ImageProcessor.cs')
| -rw-r--r-- | Emby.Drawing/ImageProcessor.cs | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 471037801..efc808738 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Extensions; +using Emby.Drawing.Common; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Controller; using MediaBrowser.Controller.Drawing; @@ -16,7 +17,6 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using Emby.Drawing.Common; namespace Emby.Drawing { @@ -215,12 +215,12 @@ namespace Emby.Drawing { CheckDisposed(); - if (!_fileSystem.FileExists(cacheFilePath)) + if (!File.Exists(cacheFilePath)) { var newWidth = Convert.ToInt32(newSize.Width); var newHeight = Convert.ToInt32(newSize.Height); - _fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath)); await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); @@ -270,7 +270,7 @@ namespace Emby.Drawing await semaphore.WaitAsync().ConfigureAwait(false); // Check again in case of contention - if (_fileSystem.FileExists(croppedImagePath)) + if (File.Exists(croppedImagePath)) { semaphore.Release(); return GetResult(croppedImagePath); @@ -280,7 +280,7 @@ namespace Emby.Drawing try { - _fileSystem.CreateDirectory(Path.GetDirectoryName(croppedImagePath)); + Directory.CreateDirectory(Path.GetDirectoryName(croppedImagePath)); await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); imageProcessingLockTaken = true; @@ -366,7 +366,7 @@ namespace Emby.Drawing /// <returns>ImageSize.</returns> public ImageSize GetImageSize(string path) { - return GetImageSize(path, _fileSystem.GetLastWriteTimeUtc(path), false); + return GetImageSize(path, File.GetLastWriteTimeUtc(path), false); } public ImageSize GetImageSize(ItemImageInfo info) @@ -399,8 +399,6 @@ namespace Emby.Drawing { size = GetImageSizeInternal(path, allowSlowMethod); - StartSaveImageSizeTimer(); - _cachedImagedSizes.AddOrUpdate(cacheHash, size, (keyName, oldValue) => size); } @@ -415,26 +413,28 @@ namespace Emby.Drawing /// <returns>ImageSize.</returns> private ImageSize GetImageSizeInternal(string path, bool allowSlowMethod) { + ImageSize size; + try { - using (var file = TagLib.File.Create(path)) - { - var image = file as TagLib.Image.File; - - var properties = image.Properties; - - return new ImageSize - { - Height = properties.PhotoHeight, - Width = properties.PhotoWidth - }; - } + size = ImageHeader.GetDimensions(path, _logger, _fileSystem); } catch { + if (!allowSlowMethod) + { + throw; + } + //_logger.Info("Failed to read image header for {0}. Doing it the slow way.", path); + + CheckDisposed(); + + size = _imageEncoder.GetImageSize(path); } - return ImageHeader.GetDimensions(path, _logger, _fileSystem); + StartSaveImageSizeTimer(); + + return size; } private readonly Timer _saveImageSizeTimer; @@ -452,7 +452,7 @@ namespace Emby.Drawing try { var path = ImageSizeFile; - _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + Directory.CreateDirectory(Path.GetDirectoryName(path)); _jsonSerializer.SerializeToFile(_cachedImagedSizes, path); } catch (Exception ex) @@ -624,7 +624,7 @@ namespace Emby.Drawing await semaphore.WaitAsync().ConfigureAwait(false); // Check again in case of contention - if (_fileSystem.FileExists(enhancedImagePath)) + if (File.Exists(enhancedImagePath)) { semaphore.Release(); return enhancedImagePath; @@ -634,7 +634,7 @@ namespace Emby.Drawing try { - _fileSystem.CreateDirectory(Path.GetDirectoryName(enhancedImagePath)); + Directory.CreateDirectory(Path.GetDirectoryName(enhancedImagePath)); await _imageProcessingSemaphore.WaitAsync().ConfigureAwait(false); @@ -819,4 +819,4 @@ namespace Emby.Drawing } } } -} +}
\ No newline at end of file |
