【发布时间】:2020-03-02 10:48:59
【问题描述】:
我正在使用 ImageCapture api 从用户设备的摄像头捕获屏幕截图。
问题是在 android 上拍摄的照片旋转不正确。它们在照片预览中、图片上传之前和上传之后都旋转不正确。
我的计划是从我从图像捕获中获得的 blob 中读取 exif 数据,在 exif 中找到方向并使用 javascript 正确旋转图像, 但是没有可用的 exif 数据,因为它不是 jpg。
我的代码:
function takePhoto(img) {
imageCapture.takePhoto()
.then(blob => {
// EXIF.getData(blob, function() {
// myData = this;
// console.log( myData );
// });
let url = window.URL.createObjectURL(blob);
img.src = url;
console.log( blob );
// stop the camera and hide canavas
stream.getVideoTracks()[0].stop();
$("#webcam").hide();
image = blob;
$("#photo-info").slideDown('slow');
})
.catch(function (error) {
console.log(error);
});
};
takePhoto(document.querySelector('#camera-feed'));
有没有办法在使用 ImageCapture 时检测图像是否旋转不正确?
【问题讨论】:
标签: javascript android exif image-capture mediastream