diff --git a/Emby.Drawing/Emby.Drawing.csproj b/Emby.Drawing/Emby.Drawing.csproj
index e9911a12d..6cda8b5d0 100644
--- a/Emby.Drawing/Emby.Drawing.csproj
+++ b/Emby.Drawing/Emby.Drawing.csproj
@@ -37,7 +37,7 @@
False
- ..\packages\ImageMagickSharp.1.0.0.16\lib\net45\ImageMagickSharp.dll
+ ..\packages\ImageMagickSharp.1.0.0.17\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/ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
index 64ddf7e88..6858c6d52 100644
--- a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
+++ b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
@@ -72,11 +72,16 @@ namespace Emby.Drawing.ImageMagick
private void LogVersion()
{
- _logger.Info("ImageMagick version: " + Wand.VersionString);
+ _logger.Info("ImageMagick version: " + GetVersion());
TestWebp();
Wand.SetMagickThreadCount(1);
}
+ public static string GetVersion()
+ {
+ return Wand.VersionString;
+ }
+
private bool _webpAvailable = true;
private void TestWebp()
{
@@ -148,7 +153,7 @@ namespace Emby.Drawing.ImageMagick
DrawIndicator(originalImage, width, height, options);
originalImage.CurrentImage.CompressionQuality = quality;
- //originalImage.CurrentImage.StripImage();
+ originalImage.CurrentImage.StripImage();
originalImage.SaveImage(outputPath);
}
@@ -165,7 +170,7 @@ namespace Emby.Drawing.ImageMagick
DrawIndicator(wand, width, height, options);
wand.CurrentImage.CompressionQuality = quality;
- //wand.CurrentImage.StripImage();
+ wand.CurrentImage.StripImage();
wand.SaveImage(outputPath);
}
@@ -176,15 +181,16 @@ namespace Emby.Drawing.ImageMagick
private void ScaleImage(MagickWand wand, int width, int height)
{
- wand.CurrentImage.ResizeImage(width, height);
- //if (_config.Configuration.EnableHighQualityImageScaling)
- //{
- // wand.CurrentImage.ResizeImage(width, height);
- //}
- //else
- //{
- // wand.CurrentImage.ScaleImage(width, height);
- //}
+ var highQuality = false;
+
+ if (highQuality)
+ {
+ wand.CurrentImage.ResizeImage(width, height);
+ }
+ else
+ {
+ wand.CurrentImage.ScaleImage(width, height);
+ }
}
///
diff --git a/Emby.Drawing/packages.config b/Emby.Drawing/packages.config
index 0fcdc278e..3b8dbcab7 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.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index 6dc97100d..2a93efcde 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -133,7 +133,7 @@ namespace MediaBrowser.Common.Implementations
/// Gets the HTTP client.
///
/// The HTTP client.
- protected IHttpClient HttpClient { get; private set; }
+ public IHttpClient HttpClient { get; private set; }
///
/// Gets the network manager.
///
diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs
index 090e36ee6..ac6fd1bbe 100644
--- a/MediaBrowser.ServerApplication/MainStartup.cs
+++ b/MediaBrowser.ServerApplication/MainStartup.cs
@@ -18,6 +18,9 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using CommonIO.Windows;
+using Emby.Drawing.ImageMagick;
+using ImageMagickSharp;
+using MediaBrowser.Common.Net;
using MediaBrowser.Server.Implementations.Logging;
namespace MediaBrowser.ServerApplication
@@ -29,6 +32,10 @@ namespace MediaBrowser.ServerApplication
private static ILogger _logger;
private static bool _isRunningAsService = false;
+ private static bool _appHostDisposed;
+
+ [DllImport("kernel32.dll", SetLastError = true)]
+ static extern bool SetDllDirectory(string lpPathName);
///
/// Defines the entry point of the application.
@@ -41,6 +48,11 @@ namespace MediaBrowser.ServerApplication
var currentProcess = Process.GetCurrentProcess();
var applicationPath = currentProcess.MainModule.FileName;
+ var architecturePath = Path.Combine(Path.GetDirectoryName(applicationPath), Environment.Is64BitProcess ? "x64" : "x86");
+
+ Wand.SetMagickCoderModulePath(architecturePath);
+
+ var success = SetDllDirectory(architecturePath);
var appPaths = CreateApplicationPaths(applicationPath, _isRunningAsService);
@@ -241,6 +253,9 @@ namespace MediaBrowser.ServerApplication
{
Task.WaitAll(task);
+ task = InstallVcredistIfNeeded(_appHost, _logger);
+ Task.WaitAll(task);
+
SystemEvents.SessionEnding += SystemEvents_SessionEnding;
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
@@ -329,7 +344,7 @@ namespace MediaBrowser.ServerApplication
{
_logger.Info("Shutting down");
- _appHost.Dispose();
+ DisposeAppHost();
}
///
@@ -500,14 +515,15 @@ namespace MediaBrowser.ServerApplication
}
else
{
+ DisposeAppHost();
+
ShutdownWindowsApplication();
}
}
public static void Restart()
{
- _logger.Info("Disposing app host");
- _appHost.Dispose();
+ DisposeAppHost();
if (!_isRunningAsService)
{
@@ -522,11 +538,24 @@ namespace MediaBrowser.ServerApplication
}
}
+ private static void DisposeAppHost()
+ {
+ if (!_appHostDisposed)
+ {
+ _logger.Info("Disposing app host");
+
+ _appHostDisposed = true;
+ _appHost.Dispose();
+ }
+ }
+
private static void ShutdownWindowsApplication()
{
_logger.Info("Calling Application.Exit");
Application.Exit();
+ Environment.Exit(0);
+
_logger.Info("Calling ApplicationTaskCompletionSource.SetResult");
ApplicationTaskCompletionSource.SetResult(true);
}
@@ -544,6 +573,70 @@ namespace MediaBrowser.ServerApplication
}
}
+ private static async Task InstallVcredistIfNeeded(ApplicationHost appHost, ILogger logger)
+ {
+ try
+ {
+ var version = ImageMagickEncoder.GetVersion();
+ return;
+ }
+ catch (Exception ex)
+ {
+ logger.ErrorException("Error loading ImageMagick", ex);
+ }
+
+ try
+ {
+ await InstallVcredist().ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ logger.ErrorException("Error installing ImageMagick", ex);
+ }
+ }
+
+ private async static Task InstallVcredist()
+ {
+ var httpClient = _appHost.HttpClient;
+
+ var tmp = await httpClient.GetTempFile(new HttpRequestOptions
+ {
+ Url = GetVcredistUrl(),
+ Progress = new Progress()
+
+ }).ConfigureAwait(false);
+
+ var exePath = Path.ChangeExtension(tmp, ".exe");
+ File.Copy(tmp, exePath);
+
+ var startInfo = new ProcessStartInfo
+ {
+ FileName = exePath,
+
+ CreateNoWindow = true,
+ WindowStyle = ProcessWindowStyle.Hidden,
+ Verb = "runas",
+ ErrorDialog = false
+ };
+
+ using (var process = Process.Start(startInfo))
+ {
+ process.WaitForExit();
+ }
+ }
+
+ private static string GetVcredistUrl()
+ {
+ if (Environment.Is64BitProcess)
+ {
+ return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x64.exe";
+ }
+
+ // TODO: ARM url - https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_arm.exe
+
+ return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x86.exe";
+ }
+
///
/// Sets the error mode.
///
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index fdbcf015a..e8d5b6d27 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -22,7 +22,7 @@
DEBUG;TRACE
prompt
4
- true
+ false
AnyCPU
@@ -32,6 +32,7 @@
TRACE
prompt
4
+ false
MediaBrowser.ServerApplication.MainStartup
@@ -64,8 +65,9 @@
False
..\packages\CommonIO.1.0.0.5\lib\net45\CommonIO.dll
-
- ..\packages\ImageMagickSharp.1.0.0.16\lib\net45\ImageMagickSharp.dll
+
+ False
+ ..\packages\ImageMagickSharp.1.0.0.17\lib\net45\ImageMagickSharp.dll
..\packages\MediaBrowser.IsoMounting.3.0.69\lib\net45\MediaBrowser.IsoMounter.dll
@@ -176,235 +178,887 @@
MediaBrowser.Updater.exe
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
+
+
+ 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
+
+
+ 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
+
+
+ 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
-
+
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
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
PreserveNewest
+
+ {08fff49b-f175-4807-a2b5-73b0ebd9f716}
+ Emby.Drawing
+
{4fd51ac5-2c16-4308-a993-c3a84f3b4582}
MediaBrowser.Api
diff --git a/MediaBrowser.ServerApplication/Native/Autorun.cs b/MediaBrowser.ServerApplication/Native/Autorun.cs
index 2cacaae8e..c384d0460 100644
--- a/MediaBrowser.ServerApplication/Native/Autorun.cs
+++ b/MediaBrowser.ServerApplication/Native/Autorun.cs
@@ -17,25 +17,10 @@ namespace MediaBrowser.ServerApplication.Native
/// The file system.
public static void Configure(bool autorun, IFileSystem fileSystem)
{
- var shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3", "Media Browser Server.lnk");
-
- if (!Directory.Exists(Path.GetDirectoryName(shortcutPath)))
- {
- shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Emby", "Emby Server.lnk");
- }
+ var shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Emby", "Emby Server.lnk");
var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
- // Remove lnk from old name
- try
- {
- fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Media Browser Server.lnk"));
- }
- catch
- {
-
- }
-
if (autorun)
{
//Copy our shortut into the startup folder for this user
diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config
index dec8199cc..3ea97a30e 100644
--- a/MediaBrowser.ServerApplication/packages.config
+++ b/MediaBrowser.ServerApplication/packages.config
@@ -1,7 +1,7 @@
-
+