feat: log imagePath when failed to generate Thumbhash

This commit is contained in:
Max Richter 2025-05-14 19:37:24 +02:00
parent 8e293c204d
commit 50ce8b3ff7

View File

@ -9,7 +9,7 @@ async function getSharp(): Promise<typeof import("sharp") | undefined> {
return s; return s;
} }
export async function generateThumbHash(image: { width: number, height: number }) { export async function generateThumbHash(image: ImageMetadata) {
const sharp = await getSharp(); const sharp = await getSharp();
if (!sharp) return; if (!sharp) return;
@ -20,7 +20,6 @@ export async function generateThumbHash(image: { width: number, height: number }
const smallHeight = Math.floor(image.height * scaleFactor); const smallHeight = Math.floor(image.height * scaleFactor);
try { try {
//@ts-ignore //@ts-ignore
const smallImg = await sharp(image.fsPath) const smallImg = await sharp(image.fsPath)
.resize(smallWidth, smallHeight) .resize(smallWidth, smallHeight)
@ -32,7 +31,8 @@ export async function generateThumbHash(image: { width: number, height: number }
const buffer = rgbaToThumbHash(smallWidth, smallHeight, smallImg); const buffer = rgbaToThumbHash(smallWidth, smallHeight, smallImg);
return Buffer.from(buffer).toString("base64"); return Buffer.from(buffer).toString("base64");
} catch (error) { } catch (error) {
console.log("Could not generate thumbhash", error) //@ts-ignore
console.log(`Could not generate thumbhash for ${image.fsPath}`, error)
return undefined return undefined
} }