From 23a062103a90caa70963f12fd06b035b8e122305 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 6 Mar 2015 12:50:14 -0500 Subject: [PATCH] move image magick files --- .../Drawing/ImageHeader.cs | 28 +---- .../Drawing/ImageProcessor.cs | 32 ++++- MediaBrowser.ServerApplication/MainStartup.cs | 2 +- .../MediaBrowser.ServerApplication.csproj | 109 +++++++++--------- 4 files changed, 88 insertions(+), 83 deletions(-) diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageHeader.cs b/MediaBrowser.Server.Implementations/Drawing/ImageHeader.cs index 6287d0bb86..7117482c8a 100644 --- a/MediaBrowser.Server.Implementations/Drawing/ImageHeader.cs +++ b/MediaBrowser.Server.Implementations/Drawing/ImageHeader.cs @@ -1,5 +1,4 @@ -using ImageMagickSharp; -using MediaBrowser.Common.IO; +using MediaBrowser.Common.IO; using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Logging; using System; @@ -47,32 +46,13 @@ namespace MediaBrowser.Server.Implementations.Drawing /// The image was of an unrecognised format. public static ImageSize GetDimensions(string path, ILogger logger, IFileSystem fileSystem) { - try + using (var fs = File.OpenRead(path)) { - using (var fs = File.OpenRead(path)) + using (var binaryReader = new BinaryReader(fs)) { - using (var binaryReader = new BinaryReader(fs)) - { - return GetDimensions(binaryReader); - } + return GetDimensions(binaryReader); } } - catch - { - logger.Info("Failed to read image header for {0}. Doing it the slow way.", path); - } - - using (var wand = new MagickWand()) - { - wand.PingImage(path); - var img = wand.CurrentImage; - - return new ImageSize - { - Width = img.Width, - Height = img.Height - }; - } } /// diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs index 64c812e1bd..80cfd7f3ed 100644 --- a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs +++ b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs @@ -203,7 +203,7 @@ namespace MediaBrowser.Server.Implementations.Drawing try { CheckDisposed(); - + var newWidth = Convert.ToInt32(newSize.Width); var newHeight = Convert.ToInt32(newSize.Height); @@ -329,7 +329,7 @@ namespace MediaBrowser.Server.Implementations.Drawing try { Directory.CreateDirectory(Path.GetDirectoryName(croppedImagePath)); - + using (var wand = new MagickWand(originalImagePath)) { wand.CurrentImage.TrimImage(10); @@ -450,12 +450,34 @@ namespace MediaBrowser.Server.Implementations.Drawing /// ImageSize. private ImageSize GetImageSizeInternal(string path) { - CheckDisposed(); - var size = ImageHeader.GetDimensions(path, _logger, _fileSystem); + ImageSize size; + + try + { + size = ImageHeader.GetDimensions(path, _logger, _fileSystem); + } + catch + { + _logger.Info("Failed to read image header for {0}. Doing it the slow way.", path); + + CheckDisposed(); + + using (var wand = new MagickWand()) + { + wand.PingImage(path); + var img = wand.CurrentImage; + + size = new ImageSize + { + Width = img.Width, + Height = img.Height + }; + } + } StartSaveImageSizeTimer(); - return new ImageSize { Width = size.Width, Height = size.Height }; + return size; } private readonly Timer _saveImageSizeTimer; diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 4bf51bc6b1..598ec1fd79 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.ServerApplication var applicationPath = currentProcess.MainModule.FileName; - Wand.SetMagickCoderModulePath(Path.Combine(Path.GetDirectoryName(applicationPath), "ImageMagickCoders", "x86")); + //Wand.SetMagickCoderModulePath(Path.Combine(Path.GetDirectoryName(applicationPath), "ImageMagickCoders", "x86")); var appPaths = CreateApplicationPaths(applicationPath, _isRunningAsService); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index 7c23f93413..fb889e4f2f 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -239,163 +239,163 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest @@ -455,6 +455,9 @@ MediaBrowser.XbmcMetadata + + +