I'm attempting to use piexifjs to add exif data to captured images in an expo app.
const exifObj = piexif.load(base64Image);
exifObj["GPS"][piexif.GPSIFD.GPSLatitudeRef] = lat;
exifObj["GPS"][piexif.GPSIFD.GPSLongitudeRef] = lon;
const exifStr = piexif.dump(exifObj);
const inserted = piexif.insert(exifStr, base64Image);
const base64Code = inserted.split("data:image/jpeg;base64,")[1];
await writeAsStringAsync(image.uri, base64Code, {
encoding: EncodingType.Base64,
});
This code successfully adds the exif data to the image. However, the exif methods take a long time to finish (usually about 20 seconds) and they block the rest of my application until they are completed. I have tried calling them inside an async function and from an expo TaskManager defined task. In both cases, my app freezes until the piexif processes are finished. Is there a way to run piexifjs methods asynchronously?