经纬度信息"/>
读取图片经纬度信息
<!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>
更多推荐
读取图片经纬度信息
发布评论