Yoa*_*oav 5 .net c# asp.net exif exiflib
我正忙着从我的JPEG中读取EXIF数据.我觉得这很容易做到.
到目前为止,我已经为我家人的在线图片库完成了以下步骤(使用C#/ ASP.Net 3.5):
我想从原始JPEG图像中提取纬度和经度,然后在插入文件名和类别ID的同一个proc中将这些值插入到我的数据库中(步骤#5).我需要这些值才能使用Google Maps API.最简单的方法是什么?
更新:
ExifLib看起来很棒,但是当我执行以下操作时:
double d;
ExifReader er = new ExifReader(sFileName);
er.GetTagValue<double>(ExifTags.GPSLatitude, out d);
Run Code Online (Sandbox Code Playgroud)
我在最后一行收到此错误:
指定演员表无效.
有什么建议?
为了将所有答案放在一起,这是完整的解决方案.
using (ExifReader reader = new ExifReader(e.Target))
{
Double[] GpsLongArray;
Double[] GpsLatArray;
Double GpsLongDouble;
Double GpsLatDouble;
if (reader.GetTagValue<Double[]>(ExifTags.GPSLongitude, out GpsLongArray)
&& reader.GetTagValue<Double[]>(ExifTags.GPSLatitude, out GpsLatArray))
{
GpsLongDouble = GpsLongArray[0] + GpsLongArray[1] / 60 + GpsLongArray[2] / 3600;
GpsLatDouble = GpsLatArray[0] + GpsLatArray[1] / 60 + GpsLatArray[2] / 3600;
Console.WriteLine("The picture was taken at {0},{1}", GpsLongDouble, GpsLatDouble);
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
The picture was taken at 76.8593333333333,39.077
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10539 次 |
| 最近记录: |