From 5333e8053b9b41676a3c4ddd34cbd5d61df16b77 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Tue, 4 Apr 2023 19:17:44 +0200 Subject: [PATCH] Extracting interesting stuff from exif --- src/components/import/ImportSingleFile.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/import/ImportSingleFile.tsx b/src/components/import/ImportSingleFile.tsx index 66d0566..ef6d942 100644 --- a/src/components/import/ImportSingleFile.tsx +++ b/src/components/import/ImportSingleFile.tsx @@ -91,20 +91,35 @@ const ImportSingleFile: Component = ({ file: file }) => { reader.addEventListener( 'load', async () => { - // this will then display a text gpxfile - const tags = ExifReader.load(reader.result); + const tags = ExifReader.load(reader.result, { expanded: true }); + const exif = tags.exif; + const dateSegments = exif?.DateTimeOriginal?.value[0].split(' '); + const date = `${dateSegments[0].replaceAll(':', '-')}T${ + dateSegments[1] + }.${exif?.SubSecTimeOriginal?.value[0] || '0'}${ + exif?.OffsetTimeOriginal?.value[0] + }`; + const id = exif?.ImageUniqueID?.value[0]; + const gps = tags.gps; + const thumbnail = tags.Thumbnail; + const thumbnailSrc = `data:${thumbnail?.type};base64,${thumbnail?.base64}`; console.log({ caller: 'ImportSingleFile / Jpeg', file, type: file.type, result: reader.result, tags, + date, + id, + gps, + thumbnailSrc, }); //parseGpx(reader.result); }, false ); } else { + // GPX reader.readAsText(file); reader.addEventListener( 'load',