Closed maximousblk closed 2 years ago
You can not use needle in browser (and can not fetch images from any domain, due securuty policy). If you need to analyze binary data - use /sync.js
only.
@puzrin can you please give me an example of how to do that
nevermind, I figured it out: https://github.com/maximousblk/maximousblk.me/blob/41661f38e7403e4361237384e0cd62eab681e64c/lib/notion.ts#L144-L147
you have to download the whole image but that's the only way it works:
import probe from "probe-image-size/sync";
const img = await fetch("https://example.com/image.jpg").then((res) => res.arrayBuffer());
size = probe(new Buffer(img));
console.log(size);
I'm trying to use
probe-image-size
for getting image dimensions to use NextJS'<Image />
component. It works in dev (next dev
) but throws the following error in prod (next build
)Any way to get around this?