Error CS7069 Reference to type 'Image' claims it is defined in 'System.Drawing', but it could not be found

3.1k views Asked by At

I had the original Problem that System.Drawing does not work in UWP applications. after a short web search ImageProcessor (https://imageprocessor.org/imageprocessor/#about) showed up. My current situation is:

I am trying to change a white image to an certain color, now it seams that ImageProcessor uses System.Drawing.Color but that makes no problem. What does make a problem is that if i address an object of ImageFactory it responds with this error Message: CS7069 Reference to type 'Image' claims it is defined in 'System.Drawing', but it could not be found.

Here is my Code:

byte[] photoBytes = File.ReadAllBytes(source);

                        using (MemoryStream inStream = new MemoryStream(photoBytes))
                        {
                            using (MemoryStream outStream = new MemoryStream())
                            {
                                using (ImageFactory imageFactory = new ImageFactory(preserveExifData: true))
                                {
                                    imageFactory.Load(inStream).BackgroundColor(Color.FromArgb(argb[0],argb[1],argb[2], argb[3])).Save(outStream);
                                }
                            }
                        }

The red line is under imageFactory.Load.

If you know how to fix this or if you know hoe to do it different that would be cool. Thank you in advance

1

There are 1 answers

2
Alex Leo On BEST ANSWER

I have managed to install ImageProcessor in a uwp app and I got the following warning:

ImageProcessor 2.9.1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework 'UAP,Version=v10.0.17763'. This package may not be fully compatible with your project.

Made a .net Core console app - same warning.

It appears that ImageProcessor requires a .Net target framework.

In-fact I have made a simple .net 4.7 console app and this is the result:

enter image description here

On inspection of the nuget packages it clearly states the dependency:

enter image description here