Exif.js 讀取相片的元數據 (例如手機拍照時的GPS定位信息,拍攝時間等等)


使用Exif.js讀取照片的GPS信息和拍攝時間

 

 1 getImgLocation(img) {
 2       return new Promise(resolve => {
 3         EXIF.getData(img, function() {
 4           // const data = EXIF.getAllTags(img)
 5           // console.log(data)
 6 
 7           const shootTime = EXIF.getTag(this, 'DateTime')
 8           const tagj = EXIF.getTag(this, 'GPSLongitude')
 9           const tagw = EXIF.getTag(this, 'GPSLatitude')
10           if (tagj && tagw) {
11             const lng = tagj[0] + tagj[1] / 60 + tagj[2] / 60 / 60
12             const lat = tagw[0] + tagw[1] / 60 + tagw[2] / 60 / 60
13             resolve({ lng: lng, lat: lat, shootTime: shootTime })
14           }
15           resolve({})
16         })
17       })
18     }

 

 
 

原文檔里還有其他方法及介紹

http://code.ciaoca.com/javascript/exif-js/

 

 

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM