简体   繁体   English

C#检索佳能特定EXIF数据

[英]C# Retrieve Canon Specific EXIF Data

I have written an app that reads the basic EXIF data from an image via the PropertyItems exposed in .Net's System.Drawing.Image class. 我编写了一个应用程序,通过.Net的System.Drawing.Image类中公开的PropertyItems从图像中读取基本的EXIF数据。 However, I cannot retrieve Canon specific EXIF data via these properties. 但是,我无法通过这些属性检索佳能特定的EXIF数据。 How does one read this information? 如何阅读这些信息? I know it exists in the file, as Photoshop reads it. 我知道它存在于文件中,因为Photoshop会读取它。

I found this a while ago but haven't used it yet. 我刚才发现了这个,但还没有使用它。 It looked like it had manufacturer specific info. 看起来它有制造商的具体信息。

http://renaud91.free.fr/MetaDataExtractor/ http://renaud91.free.fr/MetaDataExtractor/

UPDATE: 更新:

The metadata-extractor project has been alive and well since 2002 for Java, and is now available for .NET. 自2002年以来,元数据提取器项目一直活跃在Java上,现在可用于.NET。 It has comprehensive support for Canon's makernotes as well as those from Agfa, Casio, Epson, Fujifilm, Kodak, Kyocera, Leica, Minolta, Nikon, Olympus, Panasonic, Pentax, Sanyo, Sigma/Foveon and Sony cameras and scanners. 它全面支持佳能的制造商以及来自爱克发,卡西欧,爱普生,富士,柯达,京瓷,徕卡,美能达,尼康,奥林巴斯,松下,宾得,三洋,Sigma / Foveon以及索尼相机和扫描仪的制造商。

You can browse example output for several Canon (and other) camera images here. 您可以在此处浏览多个佳能(和其他)相机图像的示例输出。

The library is available via NuGet or GitHub. 该库可通过NuGet或GitHub获得。

Sample usage: 样品用法:

IEnumerable<Directory> directories = ImageMetadataReader.ReadMetadata(path);

foreach (var directory in directories)
foreach (var tag in directory.Tags)
{
    Console.Out.WriteLine($"{directory.Name} - {tag.TagName} = {tag.Description}");
}

see an updated answer here: C# Retrieve Canon Specific EXIF Data 请在此处查看更新的答案: C#检索Canon特定的EXIF数据

If you're compiling against v3 of the Framework (or later), then you can load the images using the BitmapSource class , which exposes the EXIF metadata through the Metadata property . 如果您正在针对框架(或更高版本)的v3进行编译,那么您可以使用BitmapSource加载图像, 该类通过Metadata属性公开EXIF元Metadata This gives a much closer connection to the EXIF information in the pictures, although the maker notes are specific and will need further decoding. 这提供了与图片中的EXIF信息更紧密的连接,尽管制造者注释是特定的并且将需要进一步解码。

The metadata-extractor project has been alive and well since 2002 for Java, and is now available for .NET. 自2002年以来, 元数据提取器项目一直活跃在Java上,现在可用于.NET。 It has comprehensive support for Canon's makernotes as well as those from Agfa, Casio, Epson, Fujifilm, Kodak, Kyocera, Leica, Minolta, Nikon, Olympus, Panasonic, Pentax, Sanyo, Sigma/Foveon and Sony cameras and scanners. 它全面支持佳能的制造商以及来自爱克发,卡西欧,爱普生,富士,柯达,京瓷,徕卡,美能达,尼康,奥林巴斯,松下,宾得,三洋,Sigma / Foveon以及索尼相机和扫描仪的制造商。

You can browse example output for several Canon (and other) camera images here . 您可以在此处浏览多个佳能(和其他)相机图像的示例输出。

The library is available via NuGet or GitHub . 该库可通过NuGetGitHub获得

Sample usage: 样品用法:

IEnumerable<Directory> directories = ImageMetadataReader.ReadMetadata(path);

foreach (var directory in directories)
foreach (var tag in directory.Tags)
{
    Console.Out.WriteLine($"{directory.Name} - {tag.TagName} = {tag.Description}");
}

Note that the lib in Mark Redman's answer is an outdated port of my Java library from many years ago. 请注意, Mark Redman的答案中的lib是多年前我的Java库的过时端口。 I now maintain both the C# and Java projects to have feature parity. 我现在维护C#和Java项目以具有功能奇偶校验。

There isn't anything built into the BCL that will help with EXIF. BCL中没有任何内容可以帮助EXIF。

Look at this SO question and the answers (What is the best EXIF library for .Net?). 看看这个问题和答案(什么是.Net最好的EXIF库?)。 There are several commercial and open source libraries that you can use to get EXIF data. 您可以使用几个商业和开源库来获取EXIF数据。

如果它们是RAW文件,您可以尝试使用dcraw.net来获取信息。

I wrote a forensic tool a few months ago in C# and used Phil Harvey's EXIF Tool to get the EXIF data from photographs. 几个月前我在C#中编写了一个取证工具,并使用Phil Harvey的EXIF工具从照片中获取EXIF数据。 Yep, it's a PERL library but it was really easy to install and integrate into my C# application. 是的,这是一个PERL库,但它很容易安装并集成到我的C#应用​​程序中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM