读取图片经纬度信息

编程入门 行业动态 更新时间:2024-10-14 02:19:55

读取图片<a href=https://www.elefans.com/category/jswz/34/1769711.html style=经纬度信息"/>

读取图片经纬度信息

<!DOCTYPE html>
<html><head><title>获取图片的经纬度</title><script src=".3.0/exif.min.js"></script></head><body><input type="file" id="imageInput" accept="image/*" /><div id="result"></div><script>console.log(typeof undefined);function handleImageUpload(event) {const file = event.target.files[0];const reader = new FileReader();reader.onload = function (e) {const image = new Image();image.src = e.target.result;image.onload = function () {EXIF.getData(image, function () {const lat = EXIF.getTag(this, "GPSLatitude");const lon = EXIF.getTag(this, "GPSLongitude");if (lat && lon) {const latitude = convertDMSToDD(lat);const longitude = convertDMSToDD(lon);document.getElementById("result").textContent = `经度: ${longitude}, 纬度: ${latitude}`;} else {document.getElementById("result").textContent ="该图片没有经纬度信息。";}});};};reader.readAsDataURL(file);}function convertDMSToDD(coordinates) {const [degrees, minutes, seconds] = coordinates;const decimal = degrees + minutes / 60 + seconds / 3600;return decimal;}document.getElementById("imageInput").addEventListener("change", handleImageUpload);</script></body>
</html>

更多推荐

读取图片经纬度信息

本文发布于:2024-02-06 13:39:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1749296.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:经纬度   图片   信息

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!