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不能在远程图像上工作?