获取NEF格式图像的日期 [英] Get Date Taken for NEF format images

查看:92
本文介绍了获取NEF格式图像的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个函数可以获取JPEG格式的图片的日期值。我遇到了NEF尼康原始格式的问题。在Windows 8中,如果将列添加到Windows资源管理器详细信息视图中,则可以看到采用日期值。

I have a function that gets the date taken value for pictures in JPEG format. I've run into a problem with the NEF Nikon raw format. In Windows 8 I can see the Date Taken value if I add the column to the Windows Explorer detail view.

执行以下操作时收到的错误是此编解码器不支持指定的属性。

The error I receive when the following is executed is "This codec does not support the specified property."

public string GetDate(FileInfo f)
        {
            string date;

            using (FileStream fs = new FileStream(f.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
            { 
                BitmapSource img = BitmapFrame.Create(fs);
                BitmapMetadata md = (BitmapMetadata)img.Metadata;
                date = md.DateTaken;
            }

            return date;
        }

我在这个文章在类似的SO答案中引用,使用BitmapMetadata的GetQuery方法,但返回了相同的错误,这是我使用的代码:

I tried the suggestion in this article that is referenced in similar SO answers, using the GetQuery method for BitmapMetadata, but that returned the same error, here was the code I used:

public string GetDate(FileInfo f)
        {
            string date;

            using (FileStream fs = new FileStream(f.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
            { 
                BitmapSource img = BitmapFrame.Create(fs);
                BitmapMetadata md = (BitmapMetadata)img.Metadata;
                object t = Mdata.GetQuery("System.Photo.DateTaken");
            }

            return date;
        }

我正在将其部署到Windows 8 PC,所以我不这样做介意Windows 8或.NET 4.5唯一的解决方案。

I'm deploying this to a Windows 8 PC, so I don't mind a Windows 8 or .NET 4.5 only solution.

推荐答案

我终于找到了问题,我不得不安装尼康NEF编解码器。令我感到困惑的是,Windows 8能够显示NEF图像并提供EXIF的元数据,例如Date Taken,开箱即用。我的直觉告诉我,我可以使用Windows或.NET库,我可以在不安装编解码器的情况下获得相同的信息。不幸的是,我时间紧迫,没有时间深入潜水。

I finally figured out the issue, I had to install the Nikon NEF Codec on my PC. What I'm confused about is that Windows 8 is able to display NEF images and provide metadata from EXIF such as Date Taken, out of the box. My gut tells me that there is a Windows or .NET library I could use that I could obtain the same information without installing the codec. Unfortunately I'm pressed for time and don't have time to dive deeper.

这篇关于获取NEF格式图像的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆