fix: some stuff
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
const iso = (d: string | Date) => {
|
||||
if(!d) return ""
|
||||
const v = toDate(d);
|
||||
if(!v) return ""
|
||||
return isNaN(v.getTime()) ? "" : v.toISOString();
|
||||
};
|
||||
|
||||
|
||||
BIN
src/content/photos/picos-de-europa/index.mdx
(Stored with Git LFS)
BIN
src/content/photos/picos-de-europa/index.mdx
(Stored with Git LFS)
Binary file not shown.
@@ -1,6 +1,7 @@
|
||||
import { rgbaToThumbHash } from "thumbhash";
|
||||
import ExifReader from "exifreader";
|
||||
import type { ImageMetadata } from "astro";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import sharp from "sharp";
|
||||
|
||||
export async function generateThumbHash(
|
||||
@@ -72,23 +73,26 @@ const allowedExif = [
|
||||
];
|
||||
|
||||
export async function getExifData(image: ImageMetadata) {
|
||||
if (image.format === "svg") return undefined; // SVGs don't have EXIF data")
|
||||
if (image.format === "svg") return undefined; // SVGs don't have EXIF data
|
||||
const imagePath = (image as ImageMetadata & { fsPath: string }).fsPath ??
|
||||
image.src;
|
||||
|
||||
if (!imagePath) return undefined;
|
||||
|
||||
try {
|
||||
let buffer: ArrayBuffer;
|
||||
let buffer: ArrayBufferLike;
|
||||
if (imagePath.startsWith("https://") || imagePath.startsWith("http://")) {
|
||||
const res = await fetch(imagePath);
|
||||
buffer = await res.arrayBuffer();
|
||||
} else {
|
||||
buffer = await sharp(imagePath).toBuffer() as unknown as ArrayBuffer;
|
||||
const b = await readFile(imagePath);
|
||||
buffer = b.buffer;
|
||||
}
|
||||
|
||||
const tags = await ExifReader.load(buffer, { async: true });
|
||||
|
||||
if (!buffer) return undefined;
|
||||
|
||||
const out: Record<string, any> = {};
|
||||
let hasExif = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user