Reading exif tags

This commit is contained in:
Eric van der Vlist 2023-04-04 15:25:53 +02:00
parent 854a9d701a
commit f52191966c
1 changed files with 39 additions and 17 deletions

View File

@ -19,6 +19,7 @@ import {
Filesystem as CapacitorFileSystem,
Encoding,
} from '@capacitor/filesystem';
import ExifReader from 'exifreader';
interface Props {
file: File;
@ -84,21 +85,42 @@ const ImportSingleFile: Component<Props> = ({ file: file }) => {
parseGpx(content.data);
});
} else {
const gpxReader = new FileReader();
gpxReader.readAsText(file);
gpxReader.addEventListener(
'load',
async () => {
// this will then display a text gpxfile
console.log({
caller: 'ImportSingleFile / XML',
gpxFile: file,
result: gpxReader.result,
});
parseGpx(gpxReader.result);
},
false
);
const reader = new FileReader();
if (file.type === 'image/jpeg') {
reader.readAsArrayBuffer(file);
reader.addEventListener(
'load',
async () => {
// this will then display a text gpxfile
const tags = ExifReader.load(reader.result);
console.log({
caller: 'ImportSingleFile / Jpeg',
file,
type: file.type,
result: reader.result,
tags,
});
//parseGpx(reader.result);
},
false
);
} else {
reader.readAsText(file);
reader.addEventListener(
'load',
async () => {
// this will then display a text gpxfile
console.log({
caller: 'ImportSingleFile / XML',
file,
type: file.type,
result: reader.result,
});
parseGpx(reader.result);
},
false
);
}
}
const doImport = async () => {
setState('importing');
@ -113,9 +135,9 @@ const ImportSingleFile: Component<Props> = ({ file: file }) => {
tech:
typeof file === 'string'
? {
importDate: new Date().toISOString(),
importDate: new Date().toISOString(),
uri: file,
}
}
: {
lastModified: new Date(file.lastModified).toISOString(),
importDate: new Date().toISOString(),