Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPEG decoder for .NET Core

there is currently no "built in" JPEG decoder class for .NET Core since System.Drawing (except for System.Drawing.Primitives) is currently not present as a nuget package. I do understand that System.Drawing relies on underlying Win32 GDI code which obviously is not present on all platforms.

I did read some posts about possible implementations and there appear to be some alpha-grade JPEG packages on nuget but I haven't been able to find a proper one.

Does anyone know about a simple way of DECODING JPEG pictures on .NET Core for some server side processing? I don't even need resize or other functions, decoding would suffice perfectly.

Help is greatly appreciated. Thanks in advance!
-Simon

like image 373
Simon Mattes Avatar asked Sep 08 '25 15:09

Simon Mattes


2 Answers

Have a look at https://github.com/JimBobSquarePants/ImageSharp

With a usage like in these samples:

Sample 1:

// resizing and filter (grayscale)
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)
         .Grayscale()
         .Save(output);
}

Sample 2: Accessing Pixels

Image image = new Image(400, 400);
using (PixelAccessor<Color, uint> pixels = image.Lock())
{
    pixels[200, 200] = Color.White;
}
like image 56
Ralf Bönning Avatar answered Sep 10 '25 05:09

Ralf Bönning


There is an ImageMagick wrapper for .net which looks like it now supports .Net Core: https://magick.codeplex.com

like image 24
Mark Redman Avatar answered Sep 10 '25 04:09

Mark Redman