Some of you might already know that there is “currently” not any built in default JPEG decoder class for .NET Core since System.Drawing (except for System.Drawing.Primitives) is currently not present as a Nuget package.
So is there any way of DECODING JPEG pictures on .NET Core for some server side processing?
Yes certainly there is!
All you need to do is to download a Nuget package called ImageProcessor 2.4.4 which you can find here for full .NET Framework
Is it available for .Net Core?
Yes it is! It is only on MyGet for the time being. That is hosted here.
Any type supported apart from JPEG?
Encoding/decoding of image formats (plugable):
1. Jpeg (Includes Subsampling. Progressive writing required)
2. Bmp (Read: 32bit, 24bit, 16 bit. Write: 32bit, 24bit just now)
3. Png (Read: Rgb, Rgba, Grayscale, Grayscale + alpha, Palette. Write: Rgb, Rgba, Grayscale, 4. Grayscale + alpha, Palette) Needs interlaced decoding #379
5. Gif (Includes animated)
Some of basic samples are as below:
// 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)
Sample 2: Accessing Pixels
Image image = new Image(400, 400);
using (PixelAccessor<Color, uint> pixels = image.Lock())
pixels[200, 200] = Color.White;
You can find more advantages of this Nuget package here.
Thanks James Jackson-South for building this.