Avoiding raising errors when there is no elevation in exif data
This commit is contained in:
1 parent
e634d13ee5
commit
3ca64ad7eb
2 files changed
+10
-1
No files matched your search
@@ -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);
|
||||||
|
|||||||
+3
-1
@@ -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,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user