3
我有一个函数可以获取JPEG格式图片的日期值。我遇到了NEF Nikon原始格式的问题。在Windows 8中,如果将列添加到Windows资源管理器详细信息视图中,我可以看到Date Taken值。获取NEF格式图像的日期
执行以下操作时收到的错误是“此编解码器不支持指定的属性。”
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;
}
我想,在相似的,所以答案参考,使用BitmapMetadata的GetQuery方法在此article的建议,而是返回了同样的错误,这里是我使用的代码:
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解决方案。
我和你在同一条船上,只是在佳能的一面。 Jpegs很好,但是CR2图片是问题。 Windows资源管理器获取DateTaken时没有任何问题,但在通过WIC尝试时失败。 – Adarsha