【发布时间】:2014-12-22 05:33:11
【问题描述】:
我已经使用 cordova phonegap api 来打开相机
$scope.capturePhoto = function () {
navigator.camera.getPicture(onPhotoDataSuccess, onFail, {quality: 50,
destinationType: navigator.camera.DestinationType.DATA_URL, sourceType: 1});
}
$scope.capturePhotoEdit = function () {
navigator.camera.getPicture(onPhotoDataSuccess, onFail, {quality: 20, allowEdit: true,
destinationType: navigator.camera.DestinationType.DATA_URL, sourceType: 1});
}
$scope.getPhoto = function () {
navigator.camera.getPicture(onPhotoDataSuccess, onFail, {quality: 50,
destinationType: navigator.camera.DestinationType.DATA_URL, sourceType: 0});
}
$scope.getPhotoAlbum = function () {
navigator.camera.getPicture(onPhotoDataSuccess, onFail, {quality: 50,
destinationType: navigator.camera.DestinationType.DATA_URL, sourceType: 2});
}
onFail = function (message) {
$window.alert(message);
}
在 DATA_URL 长字符串中,如 base64,但 C# 中的 exif 未读取图像详细信息
如果我已经使用文件上传并转换为 base64,那么在 C# 中轻松获取 Exif 详细信息(GPS Long Lat),但不打开带有文件上传器标签的相机:
function readImage(input) {
console.log(input);
if ( input.files && input.files[0] ) {
var FR= new FileReader();
FR.onload = function(e) {
// $('#img').attr( "src", e.target.result );
$('#base').text( e.target.result );
};
FR.readAsDataURL( input.files[0] );
}
}
$("#asd").change(function(){
readImage( this );
});
在c#代码中读取Exif详细信息是:
using ExifLibrary;
byte[] data = Convert.FromBase64String(model.imagebase64);
string file = model.workId + "_" + SnapName + ".Jpeg";
string liveserverpath = ConfigurationManager.AppSettings["MyFileLocation"].ToString();
liveserverpath = liveserverpath + file;
var exif = ExifFile.Read(liveserverpath);
try
{
newmodel.P_Latitude = (exif.Properties[ExifTag.GPSLatitude]).ToString();
newmodel.P_Longitude = (exif.Properties[ExifTag.GPSLongitude]).ToString();
newmodel.Snap_Status = "Valid";
}
我的问题是:为什么 Data_URL(string) 中缺少图像详细信息以及将图像上传到 base64 的文件中容易读取图像详细信息(GPS long lat)
请告诉我,帮帮我,我在那花了一周时间,但没有从 data_URL 获得任何 exif 图像详细信息,
【问题讨论】:
-
是只有 GPS 数据丢失,还是所有 EXIF 数据?如果只是 GPS,则可能是时间问题。我知道在 Windows Phone 上,GPS 数据是在拍照后的一段时间内添加的(只要手机能够获得 GPS 信号)。这里可能发生了同样的事情。
-
缺少 Data_url 中的所有 exif 详细信息
标签: c# cordova android-camera exif exiflib