feat: add exif data to image tags
All checks were successful
Deploy to SFTP Server / build (push) Successful in 5m16s
All checks were successful
Deploy to SFTP Server / build (push) Successful in 5m16s
This commit is contained in:
parent
f55ae8a267
commit
6f433e08ce
@ -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<string, any> = {};
|
||||
let hasExif = false;
|
||||
const out: Record<string, any> = {};
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user