Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting image metadata in .NET without regards to metadata format

Given a filename, I need to be able to access certain metadata in an image for a (closed source) project I'm currently developing, without regard to how the metadata is stored (that is, Exif, IPTC, or XMP). In particular, I want to access geotagging data.

Is there a way of doing this without requiring any third party assemblies or libraries (i.e. is it doable with stock Microsoft .NET) and how would it be done? Or am I stuck with a lot of P/Invoking of WIC?

like image 521
Chris Charabaruk Avatar asked Dec 12 '25 04:12

Chris Charabaruk


2 Answers

Check the FreeImage project - a C++ image loading and processing that has .NET wrapper. perhaps it can do that

like image 79
Dror Helper Avatar answered Dec 14 '25 17:12

Dror Helper


Old question, I know, but EXIF can be extracted with just the base .NET framework (no third party DLLs). EXIF items can be extracted from an Image object as PropertyItems. I'm using a method similar to this to extract a particular property as a string (e.g. Date Taken or Maker Note):

public static string GetEXIFInfo(System.Drawing.Image img, int propertyItem) {
    return new ASCIIEncoding().GetString(img.GetPropertyItem(propertyItem).Value);
}

And here's a list of propertyitem values you can use to get various EXIF values: http://msdn.microsoft.com/en-us/library/ms534416%28VS.85%29.aspx

like image 25
Dave Cowart Avatar answered Dec 14 '25 16:12

Dave Cowart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!