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(
'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',