2

I'm having Generic GDI+ Error on line imageFactory.Load(inStream). My project is ASP.NET Core Razor-Pages.

I tried to clone inStream to new stream (this helped me before when saving bitmaps), but to no success.

Anyone dealt with something similar before?

// using ImageProcessor;
// using ImageProcessor.Imaging.Formats;

byte[] photoBytes = System.IO.File.ReadAllBytes(@"C:\Users\User\Desktop\img\img.jpg");
            ISupportedImageFormat format = new JpegFormat();
            Size size = new Size(200,200);
            using (MemoryStream inStream = new MemoryStream(photoBytes))
            {
                using (MemoryStream outStream = new MemoryStream())
                {
                    var asd = inStream;

                    using (ImageFactory imageFactory = new ImageFactory(preserveExifData: true))
                    {
                        imageFactory.Load(inStream)
                            .Resize(size)
                            .Format(format)
                            .Save(@"C:\Users\User\Desktop\ImgAdjusted\");
                    }
                }
            }
xcelm
  • 541
  • 1
  • 6
  • 19
  • 3
    1. `ImageProcessor` is not designed for `.NET Core` , see [the author's answer on SO](https://stackoverflow.com/a/50168251/10091607). 2. `ImageProcessor` is in maintainance mode only . Focus for the ImageProcessor libraries has switched to a new library `ImageSharp` – itminus Dec 21 '18 at 05:20
  • Strange - in another thread I read this is prefered package to handle image processing in .net core. Thumbs up though – xcelm Dec 21 '18 at 10:24

2 Answers2

2

As per @itminus answer - this library is not designed to work in .net core.

xcelm
  • 541
  • 1
  • 6
  • 19
2

Top 3 alternatives to ImageProcessor for .NET Core

Aside: Where did System.Drawing.Common come from? .NET Core did not initially support GDI+. Then, they came out with the windows comparability library, which would get you GDI+ on windows only. At the time of writing Microsoft has ported the GDI+ functionality using a Mono implementation.

Adam Vincent
  • 3,281
  • 14
  • 38