One of the drawbacks developers may find when trying to use .NET Core for application development is the lack of imaging-based APIs. Among the more popular APIs is the venerable System.Drawing
, but this is not available on .NET Core due to its reliance on the Windows-reliant GDI+ interface. Fortunately the broader deveoper community has stepped in to produce imaging libraries that support .NET Core.
Microsoft's Bertrand Le Roy has provided a survey and comparison of different libraries to measure their suitability, and his initial survey provides a useful basis for comparing the output and performance of these four implementations:
- CoreCompat.System.Drawing
- ImageSharp
- Magick.NET
- SkiaSharp
Developers with code already reliant on System.Drawing
will find the CoreCompat.System.Drawing library to be helpful, as it is a near drop-in replacement. However, it should be noted that when running on Windows it can suffer from locking issues.
ImageSharp is a new library written in pure-manage code. This gives it great cross-platform support at the cost of not using native code for higher performance gains.
Magick.NET is a .NET-based wrapper for the open source ImageMagick library. It offers a great deal of functionality and produces what Le Roy considers to be the best image quality, but currently only supports .NET Core on Windows. Support for additional platforms is something Magick.NET's author (Dirk Lemstra) would like to provide as ImageMagick itself is cross-platform.
SkiaSharp has a .NET wrapper for Google's Skia cross-platform 2d graphics library, however this does not support .NET Core. Miguel de Icaza has described the challenges that need to be overcome in order to provide .NET Core support.
In Le Roy’s conclusion, he notes that which library is best really depends on your current needs. CoreCompate.System.Drawing is a high performer, assuming the potential for locking-issues is tolerable in your application. Magick.NET has the best quality and file type support. Finally ImageSharp benefits from being pure managed code, and while performance is lagging the other libraries, greater optimization is possible in the near future due to its active development.