diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs
index f2e89350f..4b56168c3 100644
--- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs
+++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs
@@ -108,9 +108,28 @@ namespace NzbDrone.Common.Disk
}
}
}
+
+ public bool CanUseGDIPlus()
+ {
+ try
+ {
+ GdiPlusInterop.CheckGdiPlus();
+ return true;
+ }
+ catch (DllNotFoundException ex)
+ {
+ Logger.Trace(ex, "System does not have libgdiplus.");
+ return false;
+ }
+ }
public bool IsValidGDIPlusImage(string filename)
{
+ if (!CanUseGDIPlus())
+ {
+ return true;
+ }
+
try
{
using (var bmp = new Bitmap(filename))
@@ -120,7 +139,7 @@ namespace NzbDrone.Common.Disk
}
catch (Exception ex)
{
- //_logger.Debug(ex, "Corrupted image found at: {0}. Redownloading...", filename);
+ Logger.Debug(ex, "Corrupted image found at: {0}.", filename);
return false;
}
}
diff --git a/src/NzbDrone.Core/MediaCover/GdiPlusInterop.cs b/src/NzbDrone.Common/Disk/GdiPlusInterop.cs
similarity index 96%
rename from src/NzbDrone.Core/MediaCover/GdiPlusInterop.cs
rename to src/NzbDrone.Common/Disk/GdiPlusInterop.cs
index 659a15d41..11b4c9c51 100644
--- a/src/NzbDrone.Core/MediaCover/GdiPlusInterop.cs
+++ b/src/NzbDrone.Common/Disk/GdiPlusInterop.cs
@@ -2,7 +2,7 @@
using System.Drawing;
using NzbDrone.Common.EnvironmentInfo;
-namespace NzbDrone.Core.MediaCover
+namespace NzbDrone.Common.Disk
{
public static class GdiPlusInterop
{
diff --git a/src/NzbDrone.Common/Disk/IDiskProvider.cs b/src/NzbDrone.Common/Disk/IDiskProvider.cs
index 2159ed626..3976219d2 100644
--- a/src/NzbDrone.Common/Disk/IDiskProvider.cs
+++ b/src/NzbDrone.Common/Disk/IDiskProvider.cs
@@ -19,6 +19,7 @@ namespace NzbDrone.Common.Disk
bool FolderExists(string path);
bool FileExists(string path);
bool FileExists(string path, StringComparison stringComparison);
+ bool CanUseGDIPlus();
bool IsValidGDIPlusImage(string path);
bool FolderWritable(string path);
string[] GetDirectories(string path);
diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj
index 36fc57da3..6d06c91aa 100644
--- a/src/NzbDrone.Common/NzbDrone.Common.csproj
+++ b/src/NzbDrone.Common/NzbDrone.Common.csproj
@@ -90,6 +90,7 @@
+
@@ -258,4 +259,4 @@
-->
-
\ No newline at end of file
+
diff --git a/src/NzbDrone.Core.Test/MediaCoverTests/ImageResizerFixture.cs b/src/NzbDrone.Core.Test/MediaCoverTests/ImageResizerFixture.cs
index dc37776fa..729bf1d37 100644
--- a/src/NzbDrone.Core.Test/MediaCoverTests/ImageResizerFixture.cs
+++ b/src/NzbDrone.Core.Test/MediaCoverTests/ImageResizerFixture.cs
@@ -30,6 +30,10 @@ namespace NzbDrone.Core.Test.MediaCoverTests
Mocker.GetMock()
.Setup(v => v.DeleteFile(It.IsAny()))
.Callback(s => File.Delete(s));
+
+ Mocker.GetMock()
+ .Setup(v => v.CanUseGDIPlus())
+ .Returns(true);
}
[Test]
@@ -64,4 +68,4 @@ namespace NzbDrone.Core.Test.MediaCoverTests
File.Exists(resizedFile).Should().BeFalse();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/NzbDrone.Core/MediaCover/ImageResizer.cs b/src/NzbDrone.Core/MediaCover/ImageResizer.cs
index 9673cbec6..2bac8e91b 100644
--- a/src/NzbDrone.Core/MediaCover/ImageResizer.cs
+++ b/src/NzbDrone.Core/MediaCover/ImageResizer.cs
@@ -1,4 +1,5 @@
using ImageResizer;
+using System;
using NzbDrone.Common.Disk;
namespace NzbDrone.Core.MediaCover
@@ -21,7 +22,10 @@ namespace NzbDrone.Core.MediaCover
{
try
{
- GdiPlusInterop.CheckGdiPlus();
+ if (!_diskProvider.CanUseGDIPlus())
+ {
+ throw new Exception("Can't resize without libgdiplus.");
+ }
using (var sourceStream = _diskProvider.OpenReadStream(source))
{
diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj
index 3054e5cd2..b60a75f43 100644
--- a/src/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/src/NzbDrone.Core/NzbDrone.Core.csproj
@@ -780,7 +780,6 @@
-
@@ -1341,4 +1340,4 @@
-->
-
\ No newline at end of file
+