I'm trying to do some transformations to get a Uint8ClampedArray since I need it to run blurhash on it, a blur library you can find here, but to get the Uint8ClampedArray I need to run some transformation from the UInt8Array that I get from running .raw() function.
Is there a way where I can get a Uint8ClampedArray from the sharp library, and set a sharp from a Uint8ClampedArray? Since I need to run this backward to get a base64 image at the very end?
Yes, no luck so far, I was wondering maybe the creator or mantainers of the library can have a clue on this.
const { data, info } = await sharp('input.jpg')
.raw()
.toBuffer({ resolveWithObject: true });
data.toClampedArray() // This is the method or hack I'm looking for
No.
The Node.js Buffer type is already 8-bit unsigned so using something like Uint8ClampedArray.from(data) should "just work".
Hope this helped, please reopen with more details if not.