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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user