0
我有一個應用程序,它顯示遠程存儲在Twitter,Instagram和Flickr服務器上的圖像。我想要的是使用ExifLib來提取Exif信息(主要是GPS數據)並顯示圖像細節。在遠程圖像上使用ExifLib
這是我到目前爲止有:
string metaData = string.Empty;
string tagValue = string.Empty;
try
{
using (var wc = new WebClient())
{
byte[] imageBytes = wc.DownloadData(imgUrl);
using (var ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
{
using (ExifReader reader = new ExifReader(ms))
{
if (reader.GetTagValue<string>(ExifTags.GPSAltitude, out tagValue))
Log.Debug("GPSAltitude: " + tagValue);
if (reader.GetTagValue<string>(ExifTags.DateTimeDigitized, out tagValue))
Log.Debug("DateTimeDigitized: " + tagValue);
if (reader.GetTagValue<string>(ExifTags.DateTimeOriginal, out tagValue))
Log.Debug("DateTimeOriginal: " + tagValue);
if (reader.GetTagValue<string>(ExifTags.GPSLatitude, out tagValue))
Log.Debug("GPSLatitude: " + tagValue);
if (reader.GetTagValue<string>(ExifTags.GPSLongitude, out tagValue))
Log.Debug("GPSLongitude: " + tagValue);
}
}
}
}
catch (Exception ex)
{
Log.Exception("A problem occurred while fetching Exif data.", ex);
}
但是,每IMAGEURL是經歷似乎不能讓過去與圖像的MemoryStream的實例化ExifReader;它總是碰到Exception並且表明ExifLib找不到Exif數據,即使當我選擇明確具有Exif數據的an image from Flickr時也是如此。
我在上面的代碼中做錯了什麼,或者ExifLib不能在遠程圖像上工作?