using System.Drawing.Imaging; Imaging does not exist in the System.Drawing

11,148

Solution 1

If you take a look at the site of microsoft you will see:

"Classes within the System.Drawing.Imaging namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions."

You are creating a web application with ASP.net so this class isn't supported for your project

Solution 2

If you're looking for System.Drawing-related functionality on .NET Core, you should be able to use System.Drawing.Common.

It provides the System.Drawing API on .NET Core and works on Windows, Linux and macOS.

If you're on Linux and macOS, you'll need to install libgdiplus for this to work. To install libgdiplus on macOS, run brew install mono-libgdiplus; on Linux you should be able to install the libgdiplus package using your package manager. This deployment will hopefully get easier in the future.

It's currently in preview on NuGet as the System.Drawing.Common package.

Long term, you may want to consider migrating to other libraries such as ImageSharp.

Solution 3

As @TimonPost says, you cannot use that namespace from ASP.NET, because it relies on there being an interactive session (which is why it also won't work from a Windows Service).

If you just want an easy way to access metadata from images that works in ASP.NET Core, check out my MetadataExtractor library.

https://github.com/drewnoakes/metadata-extractor-dotnet

Share:
11,148
RyeGuy
Author by

RyeGuy

Updated on June 05, 2022

Comments

  • RyeGuy
    RyeGuy almost 2 years

    I am attempting to pull metadata from photos in a .Net Core App by using this library:

    https://www.codeproject.com/Articles/27242/ExifTagCollection-An-EXIF-metadata-extraction-libr

    However while implementing the ExifTagCollection class I am getting the Error listed in the title.

    enter image description here

    I have successfully referenced System.Drawing but it is not recognizing its drawing extension. Any help would be great. Also open to suggestions for other libraries to accomplish my goal. Thx