Skip to content

Commit 687d450

Browse files
authored
EXIF data viewer
Created with Claude 3.5 Somnet
1 parent 44e0b09 commit 687d450

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

exif.html

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>EXIF Data Viewer</title>
7+
<style>
8+
body {
9+
font-family: Arial, sans-serif;
10+
line-height: 1.6;
11+
margin: 0;
12+
padding: 20px;
13+
background-color: #f4f4f4;
14+
}
15+
.container {
16+
max-width: 800px;
17+
margin: auto;
18+
background: white;
19+
padding: 20px;
20+
border-radius: 5px;
21+
box-shadow: 0 0 10px rgba(0,0,0,0.1);
22+
}
23+
h1 {
24+
color: #333;
25+
}
26+
#file-input {
27+
margin-bottom: 20px;
28+
}
29+
#coordinates, #exif-data {
30+
margin-top: 20px;
31+
padding: 10px;
32+
background-color: #e9e9e9;
33+
border-radius: 5px;
34+
}
35+
#exif-data {
36+
white-space: pre-wrap;
37+
word-wrap: break-word;
38+
}
39+
</style>
40+
</head>
41+
<body>
42+
<div class="container">
43+
<h1>EXIF Data Viewer</h1>
44+
<input type="file" id="file-input" accept="image/*">
45+
<div id="coordinates"></div>
46+
<div id="exif-data"></div>
47+
</div>
48+
49+
<script src="https://cdnjs.cloudflare.com/ajax/libs/exif-js/2.3.0/exif.min.js"></script>
50+
<script>
51+
document.addEventListener('DOMContentLoaded', function() {
52+
const fileInput = document.getElementById('file-input');
53+
const coordinatesDiv = document.getElementById('coordinates');
54+
const exifDataDiv = document.getElementById('exif-data');
55+
56+
fileInput.addEventListener('change', handleFileSelect);
57+
58+
function handleFileSelect(event) {
59+
const file = event.target.files[0];
60+
const reader = new FileReader();
61+
62+
reader.onload = function(e) {
63+
const img = new Image();
64+
img.onload = function() {
65+
EXIF.getData(this, function() {
66+
const allTags = EXIF.getAllTags(this);
67+
displayExifData(allTags);
68+
});
69+
};
70+
img.src = e.target.result;
71+
};
72+
73+
reader.readAsDataURL(file);
74+
}
75+
76+
function displayExifData(tags) {
77+
let lat = null;
78+
let lon = null;
79+
80+
if (tags.GPSLatitude && tags.GPSLongitude) {
81+
lat = convertDMSToDD(tags.GPSLatitude, tags.GPSLatitudeRef);
82+
lon = convertDMSToDD(tags.GPSLongitude, tags.GPSLongitudeRef);
83+
}
84+
85+
if (lat !== null && lon !== null) {
86+
coordinatesDiv.innerHTML = `
87+
<h2>GPS Coordinates</h2>
88+
<p>Latitude: ${lat.toFixed(6)}</p>
89+
<p>Longitude: ${lon.toFixed(6)}</p>
90+
`;
91+
} else {
92+
coordinatesDiv.innerHTML = '<p>No GPS coordinates found in the image.</p>';
93+
}
94+
95+
exifDataDiv.innerHTML = `
96+
<h2>All EXIF Data</h2>
97+
<pre>${JSON.stringify(tags, null, 2)}</pre>
98+
`;
99+
}
100+
101+
function convertDMSToDD(dms, ref) {
102+
let dd = dms[0] + dms[1] / 60 + dms[2] / 3600;
103+
if (ref === "S" || ref === "W") {
104+
dd = dd * -1;
105+
}
106+
return dd;
107+
}
108+
});
109+
</script>
110+
</body>
111+
</html>

0 commit comments

Comments
 (0)