```
This commit is contained in:
@@ -285,9 +285,10 @@ export async function computeImagePhash(
|
|||||||
buffer: Buffer,
|
buffer: Buffer,
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
try {
|
try {
|
||||||
// Dynamic import to avoid issues if imghash native bindings aren't available
|
// Dynamic import — imghash is ESM with a default export containing { hash, hashRaw, ... }
|
||||||
const imghashModule = await import("imghash");
|
const imghashModule: { default?: { hash?: (buf: Buffer) => Promise<string> } } =
|
||||||
const hashFn = imghashModule.default?.hash ?? imghashModule.hash;
|
await import("imghash");
|
||||||
|
const hashFn = imghashModule.default?.hash;
|
||||||
if (typeof hashFn !== "function") return null;
|
if (typeof hashFn !== "function") return null;
|
||||||
const hash = await hashFn(buffer);
|
const hash = await hashFn(buffer);
|
||||||
return hash;
|
return hash;
|
||||||
|
|||||||
Reference in New Issue
Block a user