2021:
Quote from System.Drawing.Common only supported on Windows, Recommended action:
To use these APIs for cross-platform apps, migrate to one of the following libraries:
- ImageSharp
- SkiaSharp
- Microsoft.Maui.Graphics
You are able to use System.Drawing for the short term but be aware there is no support.
Alternatively, you can enable support for non-Windows platforms by setting the System.Drawing.EnableUnixSupport runtime configuration switch to true in the runtimeconfig.json file:
This configuration switch was added to give cross-platform apps that depend heavily on this package time to migrate to more modern libraries. However, non-Windows bugs will not be fixed. In addition, we may completely remove support for non-Windows platforms in a future release, even if you enable it using the runtime configuration switch.
To be able to use System.Drawing on Linux machines, you might also need to install libgdiplus
as mentioned by @saman-azadi and @alex-from-jitbit.
2017:
The System.Drawing
namespace is at the moment not part of corefx as it relies on the GDI+ features from Windows.
But there are plans to support it in the future.
But there are multiple alternatives:
CoreCompat.System.Drawing
CoreCompat.System.Drawing is a .NET Core port of the Mono implementation of System.Drawing. Like System.Drawing in .NET Framework and in Mono, CoreCompat.System.Drawing also relies on GDI+ on Windows. Caution is therefore advised, for the same reasons.
ImageSharp
ImageSharp is a brand new, pure managed code, and cross-platform image processing library. Its performance is not as good as that of libraries relying on native OS-specific dependencies, but it remains very reasonable. Its only dependency is .NET itself, which makes it extremely portable: there is no additional package to install, just reference ImageSharp itself, and you’re done.
Magick.NET
Magick.NET is the .NET wrapper for the popular ImageMagick library. ImageMagick is an open-source, cross-platform library that focuses on image quality, and on offering a very wide choice of supported image formats. It also has the same support for EXIF as ImageSharp.
(The .NET Core build of Magick.NET currently only supports Windows.)
SkiaSharp
SkiaSharp is the .NET wrapper for Google’s Skia cross-platform 2D graphics library, that is maintained by the Xamarin team. SkiaSharp is now compatible with .NET Core, and is extremely fast.
FreeImage-dotnet-core
This library is to the native FreeImage library what Magick.NET is to ImageMagick: a .NET Core wrapper. It offers a nice choice of image formats, good performance, and good visual quality.
Here are some good examples and performance analyses of the libraries mentioned above.
CoreCompat.System.Drawing.v2
. – Currency