Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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.

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

Thx for response. Not sure what you mean I am trying to integrate with a web application. Think I may be missing a System.Windows.Forms reference, checking now.... RyeGuy Mar 25, 2017 at 14:58 What are you targetting: Winforms, WPF, ASP..? Always tag your question correctly! - MSDN : 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. TaW Mar 25, 2017 at 15:02 @RyeGuy I'm not 100% sure for your issue, but CoreCompat provides System.Drawing functionality in .NET Core. I'm using it in production code deployed on Linux and it works great. I've never tried extracting Exif information, however. Just basic GDI tasks. github.com/CoreCompat/CoreCompat This suggests it might work?: blogs.msdn.microsoft.com/dotnet/2017/01/19/… ProgrammingLlama Mar 26, 2017 at 8:26

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.

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

Thx for the answer. Going to have to find a new library to pull metadata from photos that works with ASP.NET Core MVC. Any suggestions? RyeGuy Mar 25, 2017 at 15:08 Your best bet is probably ImageSharp - github.com/JimBobSquarePants/ImageSharp . However it hasn't reached a stable release yet. ChadT Mar 25, 2017 at 23:14

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

This library looks great Drew! Unfortunately if I tried installing it in the Package Manager Console and I get an error say 'Metadata extractor is not compatible with .netcoreapp1.1' RyeGuy Mar 26, 2017 at 22:14 @RyeGuy, apologies, I should have said to use the prerelease of v2 (it's an option to the package manager). It'll be released soon, and is very stable. I am holding off because I might add one or two more features to the proper 2.0 release. Drew Noakes Mar 26, 2017 at 23:18

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .