fix(gallery): filter out files without exif data
Some checks failed
Build and Push Docker Image / build (push) Failing after 1m48s
Some checks failed
Build and Push Docker Image / build (push) Failing after 1m48s
This commit is contained in:
@@ -29,38 +29,43 @@ export default defineCachedEventHandler(
|
||||
/\.(jpg|jpeg|png|webp)$/i.test(file),
|
||||
);
|
||||
|
||||
const imagesWithExif = await Promise.all(
|
||||
imageFiles.map(async (filename) => {
|
||||
const filePath = join(galleryDir, filename);
|
||||
const rawExif = await exifr.parse(filePath, {
|
||||
tiff: true,
|
||||
exif: true,
|
||||
gps: false,
|
||||
interop: false,
|
||||
ifd1: false,
|
||||
});
|
||||
const imagesWithExif = (
|
||||
await Promise.all(
|
||||
imageFiles.map(async (filename) => {
|
||||
const filePath = join(galleryDir, filename);
|
||||
const rawExif = await exifr.parse(filePath, {
|
||||
tiff: true,
|
||||
exif: true,
|
||||
gps: false,
|
||||
interop: false,
|
||||
ifd1: false,
|
||||
});
|
||||
|
||||
const exif = exifSchema.parse(rawExif);
|
||||
if (!rawExif) return null;
|
||||
const parsed = exifSchema.safeParse(rawExif);
|
||||
if (!parsed.success) return null;
|
||||
const exif = parsed.data;
|
||||
|
||||
return {
|
||||
filename,
|
||||
url: `/gallery/${filename}`,
|
||||
width: exif.ExifImageWidth,
|
||||
height: exif.ExifImageHeight,
|
||||
exif: {
|
||||
date: exif.DateTimeOriginal,
|
||||
camera: `${exif.Make} ${exif.Model}`,
|
||||
lens: exif.LensModel,
|
||||
settings: {
|
||||
aperture: `f/${exif.FNumber}`,
|
||||
shutter: `1/${Math.round(1 / exif.ExposureTime)}s`,
|
||||
iso: String(exif.ISO),
|
||||
focalLength: `${exif.FocalLength}mm`,
|
||||
return {
|
||||
filename,
|
||||
url: `/gallery/${filename}`,
|
||||
width: exif.ExifImageWidth,
|
||||
height: exif.ExifImageHeight,
|
||||
exif: {
|
||||
date: exif.DateTimeOriginal,
|
||||
camera: `${exif.Make} ${exif.Model}`,
|
||||
lens: exif.LensModel,
|
||||
settings: {
|
||||
aperture: `f/${exif.FNumber}`,
|
||||
shutter: `1/${Math.round(1 / exif.ExposureTime)}s`,
|
||||
iso: String(exif.ISO),
|
||||
focalLength: `${exif.FocalLength}mm`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}),
|
||||
);
|
||||
};
|
||||
}),
|
||||
)
|
||||
).filter((img) => img !== null);
|
||||
|
||||
return imagesWithExif;
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user