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