xcelm
xcelm

Reputation: 561

Generic GDI+ Error on Saving/loading image from MemoryStream using ImageProcessor

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\");
                    }
                }
            }

Upvotes: 2

Views: 425

Answers (2)

Adam Vincent
Adam Vincent

Reputation: 3821

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.

Upvotes: 2

xcelm
xcelm

Reputation: 561

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

Upvotes: 2

Related Questions