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) <noreply@anthropic.com>
This commit is contained in:
23
server.js
23
server.js
@@ -497,7 +497,28 @@ async function extractMetadata(buf) {
|
|||||||
if (exif.Photo?.FNumber) removed["Aperture"] = `f/${exif.Photo.FNumber}`;
|
if (exif.Photo?.FNumber) removed["Aperture"] = `f/${exif.Photo.FNumber}`;
|
||||||
if (exif.Photo?.ISOSpeedRatings) removed["ISO"] = String(exif.Photo.ISOSpeedRatings);
|
if (exif.Photo?.ISOSpeedRatings) removed["ISO"] = String(exif.Photo.ISOSpeedRatings);
|
||||||
if (exif.Photo?.FocalLength) removed["Focal Length"] = `${exif.Photo.FocalLength}mm`;
|
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.Photo?.ImageUniqueID) removed["Unique ID"] = "Removed";
|
||||||
if (exif.Image?.HostComputer) removed["Device"] = String(exif.Image.HostComputer);
|
if (exif.Image?.HostComputer) removed["Device"] = String(exif.Image.HostComputer);
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|||||||
Reference in New Issue
Block a user