Extracting interesting stuff from exif

This commit is contained in:
Eric van der Vlist 2023-04-04 19:17:44 +02:00
parent f52191966c
commit 5333e8053b
1 changed files with 17 additions and 2 deletions

View File

@ -91,20 +91,35 @@ const ImportSingleFile: Component<Props> = ({ file: file }) => {
reader.addEventListener( reader.addEventListener(
'load', 'load',
async () => { async () => {
// this will then display a text gpxfile const tags = ExifReader.load(reader.result, { expanded: true });
const tags = ExifReader.load(reader.result); 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({ console.log({
caller: 'ImportSingleFile / Jpeg', caller: 'ImportSingleFile / Jpeg',
file, file,
type: file.type, type: file.type,
result: reader.result, result: reader.result,
tags, tags,
date,
id,
gps,
thumbnailSrc,
}); });
//parseGpx(reader.result); //parseGpx(reader.result);
}, },
false false
); );
} else { } else {
// GPX
reader.readAsText(file); reader.readAsText(file);
reader.addEventListener( reader.addEventListener(
'load', 'load',