exif-js定向在android上总是返回0,但在桌面上有效



我正在使用exif-js库从上传到我的web应用程序的图像中提取方向。我需要exif方向来旋转不正确旋转的android图像。

问题是,从安卓设备上传的图像总是返回0作为其方向。

我试着把从同一台安卓设备拍摄的图像转移到桌面上,然后从那里上传,在这种情况下一切都很好,我得到了方向6。

localforage.getItem('photo').then(function(value) {
alert('inside forage');
image = value;
alert(image); // i get the image object
url = window.URL.createObjectURL(image);
alert(url); // url is correct
let preview = document.getElementById('camera-feed');
preview.src = url;
// const tags = ExifReader.load(image);
console.log( tags );
EXIF.getData(image, function() {
myData = this;
if (myData.exifdata.Orientation) {
orientation = parseInt(EXIF.getTag(this, "Orientation"));
alert(orientation); // on desktop 6, on android always 0
}
});
....

我在安卓系统上使用chrome浏览器。

在我的项目中进行了大量更改后,我使用这个库处理前端上的图像旋转

我知道你已经解决了这个问题,但如果你需要的不仅仅是方向,我仍然想推荐exifr库。或者绩效对你来说是否重要。Exifr速度快,可以处理数百张照片,而不会导致浏览器崩溃或花费很长时间:(。此外,还有一个简洁的API,你可以给它提供几乎任何东西——元素、URL、缓冲区、ArrayBuffer,甚至base64url或字符串等等。

exifr.orientation(file).then(val => {
console.log('orientation:', val)
})

最新更新