来自图像的EXIF数据使用javascript和phonegap来修复方向

时间:2013-12-26 16:44:10

标签: javascript image cordova base64 exif

我正在使用phonegap和javascript捕获图像并显示图像。在我的Android设备上显示时方向错误。做了一些研究后,我遇到了两个JS文件binaryajax.js和exif.js.我试图通过更改EXIF数据来改变图像的方向,但它不起作用。我从exif.js中的漂亮函数返回一个空字符串,它将图像作为参数并显示图像的属性。所以我尝试解码图像并使用其他功能 显示exif数据,但仍然无法正常工作,我要么是未定义的,要么是假的。

  function captureCameraPic() {
   // Take picture using device camera
   var camera = navigator.camera.getPicture(onCameraPicSuccess, onCameraPicError,
        {
            quality: 80,
            destinationType: destinationType.DATA_URL

        });

  }


 function onCameraPicSuccess(imgData)
 {
        document.getElementById('tempImg').src = "data:image/jpeg;base64," + imgData;
        document.getElementById('tempImg').onload = function()
        {
         alert(document.getElementById('tempImg').src);
         var b64 = document.getElementById('tempImg').src;
         var bin = window.atob(b64.split(',')[1]);
         alert(b64);
         var exif = EXIF.readFromBinaryFile(new BinaryFile(bin)); 
         alert(exif.Make);
         alert(EXIF.pretty(document.getElementById('tempImg')));
        }

0 个答案:

没有答案