public List<string> GetXYFromPic(String jpgPath) { List<string> sXY = new List<string>(); try { //载入图片 Image objImage = Image.FromFile(jpgPath); //取得所有的属性(以PropertyId做排序) var propertyItems = objImage.PropertyItems.OrderBy(x => x.Id); foreach (PropertyItem objItem in propertyItems) { //只取Id范围为0x0000到0x001e if (objItem.Id >= 0x0000 && objItem.Id <= 0x001e) { switch (objItem.Id) { case 0x0002://设置纬度 if (objItem.Value.Length == 24) { //degrees(将byte[0]~byte[3]转成uint, 除以byte[4]~byte[7]转成的uint) double d = BitConverter.ToUInt32(objItem.Value, 0) * 1.0d / BitConverter.ToUInt32(objItem.Value, 4); //minutes(將byte[8]~byte[11]转成uint, 除以byte[12]~byte[15]转成的uint) double m = BitConverter.ToUInt32(objItem.Value, 8) * 1.0d / BitConverter.ToUInt32(objItem.Value, 12); //seconds(將byte[16]~byte[19]转成uint, 除以byte[20]~byte[23]转成的uint) double s = BitConverter.ToUInt32(objItem.Value, 16) * 1.0d / BitConverter.ToUInt32(objItem.Value, 20); double dblGPSLatitude = (((s / 60 + m) / 60) + d); sXY.Add(dblGPSLatitude.ToString("0.00000000")); } break; case 0x0004: //设置经度 if (objItem.Value.Length == 24) { //degrees(将byte[0]~byte[3]转成uint, 除以byte[4]~byte[7]转成的uint) double d = BitConverter.ToUInt32(objItem.Value, 0) * 1.0d / BitConverter.ToUInt32(objItem.Value, 4); //minutes(将byte[8]~byte[11]转成uint, 除以byte[12]~byte[15]转成的uint) double m = BitConverter.ToUInt32(objItem.Value, 8) * 1.0d / BitConverter.ToUInt32(objItem.Value, 12); //seconds(将byte[16]~byte[19]转成uint, 除以byte[20]~byte[23]转成的uint) double s = BitConverter.ToUInt32(objItem.Value, 16) * 1.0d / BitConverter.ToUInt32(objItem.Value, 20); double dblGPSLongitude = (((s / 60 + m) / 60) + d); sXY.Add(dblGPSLongitude.ToString("0.00000000")); } break; } } if (objItem.Id == 0x9003 || objItem.Id == 0x0132)//Id为0x9003表示拍照的时间,0x0132 最后更新时间 { var propItemValue = objItem.Value; var dateTimeStr = System.Text.Encoding.ASCII.GetString(propItemValue).Trim('