From 7775641fe78329a3f3395498400df43669ceb435 Mon Sep 17 00:00:00 2001 From: Matthew Jackson Date: Fri, 13 Mar 2026 18:27:01 -0700 Subject: [PATCH] Show actual GPS coordinates and place name in removed metadata Reverse geocodes GPS coords via Nominatim to show the real location that was embedded in the photo, making it clear what was stripped. Co-Authored-By: Claude Opus 4.6 (1M context) --- server.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 10d73c0..5b11ffe 100644 --- a/server.js +++ b/server.js @@ -497,7 +497,28 @@ async function extractMetadata(buf) { if (exif.Photo?.FNumber) removed["Aperture"] = `f/${exif.Photo.FNumber}`; if (exif.Photo?.ISOSpeedRatings) removed["ISO"] = String(exif.Photo.ISOSpeedRatings); if (exif.Photo?.FocalLength) removed["Focal Length"] = `${exif.Photo.FocalLength}mm`; - if (exif.GPSInfo?.GPSLatitude) removed["GPS Location"] = "Removed ⚠️"; + if (exif.GPSInfo?.GPSLatitude && exif.GPSInfo?.GPSLongitude) { + const lat = exif.GPSInfo.GPSLatitude; + const lng = exif.GPSInfo.GPSLongitude; + const latRef = exif.GPSInfo.GPSLatitudeRef || "N"; + const lngRef = exif.GPSInfo.GPSLongitudeRef || "E"; + const latVal = typeof lat === "number" ? lat : (lat[0] + lat[1] / 60 + lat[2] / 3600); + const lngVal = typeof lng === "number" ? lng : (lng[0] + lng[1] / 60 + lng[2] / 3600); + const latFinal = latRef === "S" ? -latVal : latVal; + const lngFinal = lngRef === "W" ? -lngVal : lngVal; + let loc = `${latFinal.toFixed(4)}, ${lngFinal.toFixed(4)}`; + try { + const geoRes = await fetch(`https://nominatim.openstreetmap.org/reverse?lat=${latFinal}&lon=${lngFinal}&format=json&zoom=14`, { + headers: { "User-Agent": "PostConvert/1.0" }, + signal: AbortSignal.timeout(3000), + }); + if (geoRes.ok) { + const geo = await geoRes.json(); + if (geo.display_name) loc = geo.display_name; + } + } catch {} + removed["GPS Location"] = loc + " — Removed!"; + } if (exif.Photo?.ImageUniqueID) removed["Unique ID"] = "Removed"; if (exif.Image?.HostComputer) removed["Device"] = String(exif.Image.HostComputer); } catch {}