fix: correct EXIF GPS data extraction using exifr.gps()

The previous implementation was using exifr.parse() with pick option,
which doesn't work for GPS coordinates since latitude/longitude are
computed values, not direct EXIF fields.

Changed to use exifr.gps() method which properly extracts and computes
GPS coordinates from EXIF GPSLatitude/GPSLongitude fields.

This fixes the issue where photos with GPS EXIF data were showing
'No GPS data' in the UI.
This commit is contained in:
2025-11-16 16:22:17 +00:00
parent e18997ed95
commit 3864d3aa37

View File

@@ -32,18 +32,17 @@ export function PhotoUpload({
const extractEXIF = async (file: File): Promise<Partial<PhotoMetadata>> => {
try {
// Parse GPS data separately to get computed latitude/longitude
const gpsData = await exifr.gps(file);
// Parse other EXIF data for timestamp
const exifData = await exifr.parse(file, {
gps: true,
pick: ['latitude', 'longitude', 'DateTimeOriginal', 'CreateDate']
pick: ['DateTimeOriginal', 'CreateDate', 'DateTime']
});
if (!exifData) {
return { hasGPS: false };
}
const latitude = exifData.latitude;
const longitude = exifData.longitude;
const timestamp = exifData.DateTimeOriginal || exifData.CreateDate;
const latitude = gpsData?.latitude;
const longitude = gpsData?.longitude;
const timestamp = exifData?.DateTimeOriginal || exifData?.CreateDate || exifData?.DateTime;
return {
latitude: latitude !== undefined ? latitude : undefined,