Manipulating images with .NET Core

Gillardo picture Gillardo · Oct 26, 2015 · Viewed 45.4k times · Source

I have updated my project from .NET 4.5 to .NET Core (with ASP.NET Core). I had some very simple code in my previous version that used the bitmap object from System.Drawing to resize an image.

As I understand System.Drawing cannot be used in .NET Core because it is not cross platform, but what can be used instead?

I have googled this and cannot find anything. The only thing I can find is this post, which has no code on it what so ever.

Answer

James South picture James South · May 24, 2016

Disclaimer: This is my software.

I'm working on a cross-platform 2D Graphics library that runs on .NET Core It's currently alpha but already supports a comprehensive feature set.

https://github.com/JimBobSquarePants/ImageSharp

Example usage.

using (FileStream stream = File.OpenRead("foo.jpg"))
using (FileStream output = File.OpenWrite("bar.jpg"))
{
    Image image = new Image(stream);
    image.Resize(image.Width / 2, image.Height / 2)
         .Greyscale()
         .Save(output);
}