diff --git a/src/helpers/image.ts b/src/helpers/image.ts index 4d4f0af..d4cd669 100644 --- a/src/helpers/image.ts +++ b/src/helpers/image.ts @@ -47,16 +47,23 @@ const allowedExif = [ export async function getExifData(image: ImageMetadata) { const sharp = await getSharp(); if (!sharp) return; - const tags = await ExifReader.load((image as ImageMetadata & { fsPath: string }).fsPath, { async: true }); + try { + const tags = await ExifReader.load((image as ImageMetadata & { fsPath: string }).fsPath, { async: true }); - const out: Record = {}; - let hasExif = false; + const out: Record = {}; + let hasExif = false; - for (const key of allowedExif) { - if (!tags[key]) continue; - hasExif = true; - out[key] = tags[key].description; + for (const key of allowedExif) { + if (!tags[key]) continue; + hasExif = true; + out[key] = tags[key].description; + } + + return hasExif ? out : undefined; + } catch (error) { + + console.log("Error reading EXIF data", error); + return undefined } - return hasExif ? out : undefined; }