Avoiding raising errors when there is no elevation in exif data

This commit is contained in:
Eric van der Vlist 2023-04-21 21:28:09 +02:00
parent e634d13ee5
commit 3ca64ad7eb
2 changed files with 10 additions and 1 deletions

View File

@ -108,6 +108,13 @@ const ImportSingleFile: Component<Props> = ({ file: file }) => {
async () => { async () => {
const imageUrl = reader.result; const imageUrl = reader.result;
const exifObj = piexif.load(imageUrl); const exifObj = piexif.load(imageUrl);
console.log({
caller: 'ImportSingleFile / Jpeg',
file,
type: file.type,
result: reader.result,
exifObj,
});
const id = exifObj.Exif[piexif.ExifIFD.ImageUniqueID]; const id = exifObj.Exif[piexif.ExifIFD.ImageUniqueID];
const gps = getGps(exifObj); const gps = getGps(exifObj);
const date = getDate(exifObj); const date = getDate(exifObj);

View File

@ -21,6 +21,8 @@ export const getGps = (exifObj: any) => {
return { return {
latitude: toNumber(1), latitude: toNumber(1),
longitude: toNumber(3), longitude: toNumber(3),
elevation: exifObj.GPS[6][0] / exifObj.GPS[6][1], elevation: exifObj.GPS[6]
? exifObj.GPS[6][0] / exifObj.GPS[6][1]
: undefined,
}; };
}; };