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>> => {
|
const extractEXIF = async (file: File): Promise<Partial<PhotoMetadata>> => {
|
||||||
try {
|
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, {
|
const exifData = await exifr.parse(file, {
|
||||||
gps: true,
|
pick: ['DateTimeOriginal', 'CreateDate', 'DateTime']
|
||||||
pick: ['latitude', 'longitude', 'DateTimeOriginal', 'CreateDate']
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!exifData) {
|
const latitude = gpsData?.latitude;
|
||||||
return { hasGPS: false };
|
const longitude = gpsData?.longitude;
|
||||||
}
|
const timestamp = exifData?.DateTimeOriginal || exifData?.CreateDate || exifData?.DateTime;
|
||||||
|
|
||||||
const latitude = exifData.latitude;
|
|
||||||
const longitude = exifData.longitude;
|
|
||||||
const timestamp = exifData.DateTimeOriginal || exifData.CreateDate;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
latitude: latitude !== undefined ? latitude : undefined,
|
latitude: latitude !== undefined ? latitude : undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user