Add GPS EXIF logging
This commit is contained in:
parent
b492cf3ea2
commit
f675cc4fee
@ -15,11 +15,18 @@ export const convertUploadToPhoto = async (
|
||||
const fileExtension = getExtensionFromStorageUrl(urlOrigin);
|
||||
const photoPath = `${fileName}.${fileExtension || 'jpg'}`;
|
||||
if (stripGps) {
|
||||
console.log('Fetching original file');
|
||||
const fileBytes = await fetch(urlOrigin, { cache: 'no-store' })
|
||||
.then(res => res.arrayBuffer());
|
||||
const fileWithoutGps = await stripGpsFromFile(fileBytes);
|
||||
console.log('Uploading file without GPS');
|
||||
return putFile(fileWithoutGps, photoPath).then(async url => {
|
||||
if (url) { await deleteFile(urlOrigin); }
|
||||
if (url) {
|
||||
console.log('Deleting original file');
|
||||
await deleteFile(urlOrigin);
|
||||
} else {
|
||||
console.log('No url found');
|
||||
}
|
||||
return url;
|
||||
});
|
||||
} else {
|
||||
|
||||
@ -6,10 +6,12 @@ export const stripGpsFromFile = async (
|
||||
const base64 = Buffer.from(fileBytes).toString('base64');
|
||||
const base64Url = `data:image/jpeg;base64,${base64}`;
|
||||
|
||||
console.log('Stripping GPS from file');
|
||||
const exifObject = PiExif.load(base64Url);
|
||||
delete exifObject.GPS;
|
||||
const exifDataWithoutGps = PiExif.dump(exifObject);
|
||||
|
||||
console.log('Updating EXIF');
|
||||
const data = PiExif.insert(
|
||||
exifDataWithoutGps,
|
||||
base64Url,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user