安装exif-js
npm install exif-js --save
<script src="https://cdn.jsdelivr.net/npm/exif-js"></script>
获取拍照方向
EXIF.getTag(this, 'Orientation')
|
参数 |
描述 |
|
6 |
无旋转 0deg |
|
|
1 |
左旋转 90deg |
|
|
3 |
右旋转 90deg |
|
|
8 |
旋转 180deg |
|
<input id="file" type="file" capture="camera" accept="image/*" onchange="handleFileChange(this)">
<script src="https://cdn.jsdelivr.net/npm/exif-js"></script>
<script>
function handleFileChange(element) {
var file = element.files[0];
EXIF.getData(file, function () {
const o = EXIF.getTag(this, 'Orientation');
console.log(o);
});
}
</script>