diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs
index ad64b3079..384806c01 100644
--- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs
+++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs
@@ -122,20 +122,6 @@ public bool FileExists(string path, StringComparison stringComparison)
}
}
- public bool CanUseGDIPlus()
- {
- try
- {
- GdiPlusInterop.CheckGdiPlus();
- return true;
- }
- catch (DllNotFoundException ex)
- {
- Logger.Trace(ex, "System does not have libgdiplus.");
- return false;
- }
- }
-
public bool FolderWritable(string path)
{
Ensure.That(path, () => path).IsValidPath();
diff --git a/src/NzbDrone.Common/Disk/GdiPlusInterop.cs b/src/NzbDrone.Common/Disk/GdiPlusInterop.cs
deleted file mode 100644
index 11b4c9c51..000000000
--- a/src/NzbDrone.Common/Disk/GdiPlusInterop.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-using System.Drawing;
-using NzbDrone.Common.EnvironmentInfo;
-
-namespace NzbDrone.Common.Disk
-{
- public static class GdiPlusInterop
- {
- private static Exception _gdiPlusException;
-
- static GdiPlusInterop()
- {
- TestLibrary();
- }
-
- private static void TestLibrary()
- {
- if (OsInfo.IsWindows)
- {
- return;
- }
-
- try
- {
- // We use StringFormat as test coz it gets properly cleaned up by the finalizer even if gdiplus is absent and is relatively non-invasive.
- var strFormat = new StringFormat();
-
- strFormat.Dispose();
- }
- catch (Exception ex)
- {
- _gdiPlusException = ex;
- }
- }
-
- public static void CheckGdiPlus()
- {
- if (_gdiPlusException != null)
- {
- throw new DllNotFoundException("Couldn't load GDIPlus library", _gdiPlusException);
- }
- }
- }
-}
diff --git a/src/NzbDrone.Common/Disk/IDiskProvider.cs b/src/NzbDrone.Common/Disk/IDiskProvider.cs
index 2b6fe75fa..005fdf82e 100644
--- a/src/NzbDrone.Common/Disk/IDiskProvider.cs
+++ b/src/NzbDrone.Common/Disk/IDiskProvider.cs
@@ -19,7 +19,6 @@ public interface IDiskProvider
bool FolderExists(string path);
bool FileExists(string path);
bool FileExists(string path, StringComparison stringComparison);
- bool CanUseGDIPlus();
bool FolderWritable(string path);
string[] GetDirectories(string path);
string[] GetFiles(string path, SearchOption searchOption);
diff --git a/src/NzbDrone.Core/MediaCover/ImageResizer.cs b/src/NzbDrone.Core/MediaCover/ImageResizer.cs
index 2bac8e91b..63a202c59 100644
--- a/src/NzbDrone.Core/MediaCover/ImageResizer.cs
+++ b/src/NzbDrone.Core/MediaCover/ImageResizer.cs
@@ -1,6 +1,8 @@
-using ImageResizer;
using System;
using NzbDrone.Common.Disk;
+using SixLabors.ImageSharp;
+using SixLabors.ImageSharp.Processing;
+using SixLabors.Memory;
namespace NzbDrone.Core.MediaCover
{
@@ -16,28 +18,20 @@ public class ImageResizer : IImageResizer
public ImageResizer(IDiskProvider diskProvider)
{
_diskProvider = diskProvider;
+
+ // More conservative memory allocation
+ SixLabors.ImageSharp.Configuration.Default.MemoryAllocator = new SimpleGcMemoryAllocator();
}
public void Resize(string source, string destination, int height)
{
try
{
- if (!_diskProvider.CanUseGDIPlus())
+ using (var image = Image.Load(source))
{
- throw new Exception("Can't resize without libgdiplus.");
- }
-
- using (var sourceStream = _diskProvider.OpenReadStream(source))
- {
- using (var outputStream = _diskProvider.OpenWriteStream(destination))
- {
- var settings = new Instructions();
- settings.Height = height;
-
- var job = new ImageJob(sourceStream, outputStream, settings);
-
- ImageBuilder.Current.Build(job);
- }
+ var width = (int)Math.Floor((double)image.Width * (double)height / (double)image.Height);
+ image.Mutate(x => x.Resize(width, height));
+ image.Save(destination);
}
}
catch
diff --git a/src/NzbDrone.Core/Radarr.Core.csproj b/src/NzbDrone.Core/Radarr.Core.csproj
index 3b67b5f1f..3338bc484 100644
--- a/src/NzbDrone.Core/Radarr.Core.csproj
+++ b/src/NzbDrone.Core/Radarr.Core.csproj
@@ -7,7 +7,7 @@
-
+