一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

node.js|vue.js|jquery|angularjs|React|json|js教程|

服務器之家 - 編程語言 - JavaScript - vue使用exif獲取圖片經緯度的示例代碼

vue使用exif獲取圖片經緯度的示例代碼

2021-12-09 15:15china丶MRH JavaScript

這篇文章主要介紹了vue使用exif獲取圖片經緯度的示例代碼,幫助大家更好的利用vue獲取圖片信息,感興趣的朋友可以了解下

我上一篇文章寫了怎么壓縮圖片和旋轉。這篇寫一下怎么看圖片的經緯度

注意!!!

只有原圖有大量的元數據信息。通過拍照軟件如:b612等,拍攝的照片是軟件處理過的,所以一定要使用原圖來擦查詢

下面貼以下代碼。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<template>
 <div>
  <input type="file" id="upload" accept="image" @change="upload" />
  <span>{{textData}}</span>
 </div>
</template>
<script>
export default {
 data() {
  return {
   picValue: {},
   headerImage: '',
   textData:''
  };
 },
 components: {},
 methods: {
  upload(e) {
   console.log(e);
   let files = e.target.files || e.dataTransfer.files;
   if (!files.length) return;
   this.picValue = files[0];
   this.imgPreview(this.picValue);
  },
  imgPreview(file) {
   let self = this;
   let Orientation;
   //去獲取拍照時的信息,解決拍出來的照片旋轉問題
   self.EXIF.getData(file, function() {
    Orientation = self.EXIF.getTag(this, 'Orientation');
   });
   // 看支持不支持FileReader
   if (!file || !window.FileReader) return;
 
   if (/^image/.test(file.type)) {
    // 創建一個reader
    let reader = new FileReader();
    // 將圖片2將轉成 base64 格式
    reader.readAsDataURL(file);
    // 讀取成功后的回調
    reader.onloadend = function() {
     let result = this.result;
     let img = new Image();
     img.src = result;
     self.postImg(file);
    };
   }
  },
  postImg(val) {
   //這里寫接口
   let self = this;
   // document.getElementById('upload')
   // this.EXIF.getData(val, function(r) {
   let r = this.EXIF.getAllTags(val);
   const allMetaData = r;
   let direction;
   if (allMetaData.GPSImgDirection) {
    const directionArry = allMetaData.GPSImgDirection; // 方位角
    direction = directionArry.numerator / directionArry.denominator;
   }
   let Longitude;
   if (allMetaData.GPSLongitude) {
    const LongitudeArry = allMetaData.GPSLongitude;
    const longLongitude =
     LongitudeArry[0].numerator / LongitudeArry[0].denominator +
     LongitudeArry[1].numerator / LongitudeArry[1].denominator / 60 +
     LongitudeArry[2].numerator / LongitudeArry[2].denominator / 3600;
    Longitude = longLongitude.toFixed(8);
   }
   let Latitude;
   if (allMetaData.GPSLatitude) {
    const LatitudeArry = allMetaData.GPSLatitude;
    const longLatitude =
     LatitudeArry[0].numerator / LatitudeArry[0].denominator +
     LatitudeArry[1].numerator / LatitudeArry[1].denominator / 60 +
     LatitudeArry[2].numerator / LatitudeArry[2].denominator / 3600;
    Latitude = longLatitude.toFixed(8);
   }
   self.textData = '我是Longitude' + Longitude + ' ====== '+"我是Latitude" + Latitude
   console.log('我進來了', direction, Longitude, Latitude);
   console.log('allMetaData', allMetaData);
   //接口 axios
   // });
  }
 }
};
</script>

這個功能是下載的exif.js文件,也可以通過npm安裝依賴。不過都要掛在到原型鏈上。

以上就是vue使用exif獲取圖片經緯度的示例代碼的詳細內容,更多關于vue 獲取圖片經緯度的資料請關注服務器之家其它相關文章!

原文鏈接:https://www.cnblogs.com/maruihua/p/12095063.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 亚洲社区在线 | 亚洲va久久久噜噜噜久久狠狠 | 亚洲欧美日韩另类精品一区二区三区 | 国内精品久久久久香蕉 | 日本一卡=卡三卡免费 | 日本免费一区二区三区四区五六区 | 免费成年视频 | 欧美色图亚洲天堂 | 日韩福利网站 | 男人在线网址 | 久久精品成人免费看 | 97色伦图片7778久久 | 希岛爱理aⅴ在线中文字幕 午夜综合网 | 亚洲冬月枫中文字幕在线看 | a天堂在线视频 | www.青青操 | 91次元成年破解版 | 成人免费毛片一区二区三区 | 女仆掀起蕾丝裙被打屁股作文 | 鄂州一家三口完整版免费 | 天天gan | 国产精品天天看特色大片不卡 | 动漫人物差差差动漫人物免费观看 | 国产大片线上免费观看 | 精灵之森高清在线 | 三级午夜宅宅伦不卡在线 | 国产精品合集久久久久青苹果 | 午夜精品国产自在现线拍 | 亚洲v日韩v欧美在线观看 | 二次元美女扒开内裤露尿口 | 男人视频网站 | 翁熄性放纵交换300章 | 99国产精品热久久久久久夜夜嗨 | 美国女网址www呦女 美国复古性经典xxxxx | 国产精品一区二区三区免费视频 | 俄罗斯毛片免费大全 | 韩国三级做爰 | 99热这里只有精品免费 | 亚洲国产精品综合欧美 | 日韩免费在线看 | 精品久久99麻豆蜜桃666 |