Check for width and height before making blurhash

This commit is contained in:
Jesse Wierzbinski 2024-04-09 03:08:48 -10:00
parent bf169623c9
commit b91eb110cc
No known key found for this signature in database

View file

@ -77,15 +77,16 @@ export default apiRoute<{
? await sharp(await file.arrayBuffer()).metadata() ? await sharp(await file.arrayBuffer()).metadata()
: null; : null;
const blurhash = isImage const blurhash =
? encode( isImage && metadata?.width && metadata?.height
new Uint8ClampedArray(await file.arrayBuffer()), ? encode(
metadata?.width ?? 0, new Uint8ClampedArray(await file.arrayBuffer()),
metadata?.height ?? 0, metadata?.width ?? 0,
4, metadata?.height ?? 0,
4, 4,
) 4,
: null; )
: null;
let url = ""; let url = "";