我在Deno上使用TypeScript.我试着用blurhash.
这是我的代码:
const response = await fetch(url);
if (!response.body) {
throw new Error("Body null");
}
const clamped = new Uint8ClampedArray(await response.arrayBuffer());
var blurhash: string = encode(clamped, width, height, 4, 4,);
其中width
和height
是预先知道的.但我得到了这样的错误:
Width and height must match the pixels array
个
我读到这个issue,它似乎缺少Alpha通道之类的东西.问题是,所有的解决方案都通过使用sharp
和ensureAlpha()
来修复它.但是sharp
不是在Deno上运行的,所以我不能使用它.
有人知道我该怎么解决吗?