feat: add exif data to image tags

This commit is contained in:
2024-06-21 16:26:23 +02:00
parent 0fba894043
commit 7a70a8d0bf

View File

@@ -47,6 +47,7 @@ const allowedExif = [
export async function getExifData(image: ImageMetadata) { export async function getExifData(image: ImageMetadata) {
const sharp = await getSharp(); const sharp = await getSharp();
if (!sharp) return; if (!sharp) return;
try {
const tags = await ExifReader.load((image as ImageMetadata & { fsPath: string }).fsPath, { async: true }); const tags = await ExifReader.load((image as ImageMetadata & { fsPath: string }).fsPath, { async: true });
const out: Record<string, any> = {}; const out: Record<string, any> = {};
@@ -59,4 +60,10 @@ export async function getExifData(image: ImageMetadata) {
} }
return hasExif ? out : undefined; return hasExif ? out : undefined;
} catch (error) {
console.log("Error reading EXIF data", error);
return undefined
}
} }