System.Drawing in Linux

If you ever had to run your .NET Core applications on Linux you may have noticed that one of the main problems is the lack of System.Drawing assembly in standard .NET Core package. Even though Microsoft recommends to use System.Drawing.Common, that is not the ultimate solution. You have to run ‘sudo’ on each user machine to have libgdiplus library installed. And even after that, your rendering results will be slightly different from those you have on Windows machines. In order to cope with this issue, this article covers how to use the System.Drawing in Linux without libgdiplus library.

Using System.Drawing on Linux

Fortunately, now we have a solution. Below we will demonstrate how our .NET Graphics API, Aspose.Drawing for .NET, can help you use System.Drawing in Linux. Using Aspose.Drawing, you can get rid of graphics libraries with native code and have your images look the same on all platforms.

.NET Graphics API - Easy to Install

For installation of Aspose.Drawing on a target Linux machine you just need to have .NET Core installed. Put Aspose.Drawing.dll in your project folder and run the program. That’s all. Now you can use classes in System.Drawing namespace just like you do it from your .NET Framework applications on Windows.

To get Aspose.Drawing binaries, please download the latest version from the official website. Alternatively, you can include the API directly in your project by running the following command.

dotnet add package Aspose.Drawing

No additional components are required. Aspose.Drawing does all the drawing itself without referencing any native library. You will never receive messages like:

Unable to load DLL 'libgdiplus': The specified module could not be found.

And you don’t have to care about the version of the graphics system installed on your platform.

No Unpredictable Platform Issues

With System.Drawing.Common you can get unpredictable errors on Linux when running code that was successfully run on Windows:

WARNING *: Path conversion requested 34759680 bytes (2480 x 3504). Maximum size is 8388608 bytes.
ERROR:region.c:1155:GdipCombineRegionPath: assertion failed: (region->bitmap)

Aspose.Drawing doesn’t depend on libgdiplus, so you will be free of such problems. We have a fully managed drawing engine which means that we have no dependencies on native graphics libraries. You will no longer encounter incomprehensible platform errors and unpredictable behavior of your program.

Identical Rendering Results

Another benefit of using Aspose.Drawing is identical rendering results on all supported platforms. If you use System.Drawing.Common in .NET Core, your rendering results may look different on Windows and Linux, see the example below.

System.Drawing on Linux and Windows

With Aspose.Drawing you can create cross-platform graphic applications for Windows, Linux, or Android and you will always get the same rendering results on each platform. This was achieved by the creation of a platform-independent 2D rendering engine instead of relying on 3rd party graphics libraries.

Aside from graphical primitives, font rendering is the same across all platforms. And even though system fonts on Linux differ from Windows, you can use PrivateFontCollection to load your own set of fonts. Another way is to install a pack of Microsoft fonts into a Linux system and call text rendering functions as usual.

Try Aspose.Drawing for Free

Aspose.Drawing is available on NuGet. You can also download binaries or the MSI installer. You can use Aspose.Drawing library with restrictions or request a free trial license.

So why not try it today?


In this article, you have seen how easy it is to use System.Drawing on all platforms without any dependencies and get the same result. You can learn more about Aspose.Drawing at the official page. For any questions, please use the forum and stay tuned for future posts and guides.

See Also