I'm using sharp to resize the images for use with thumbhash with user uploaded images like so
const { data, info } = await sharp(image)
.resize({ width: 100, height: 100, fit: "inside" })
.ensureAlpha()
.raw()
.toBuffer({ resolveWithObject: true });
console.log(info)
/*
{
format: 'raw',
width: 100,
height: 100,
channels: 4,
depth: 'uchar',
premultiplied: true,
size: 40000
}
*/
const thumbhash = rgbaToThumbHash(info.width, info.height, data);
I noticed that sharp is outputting premultiplied images depending on the import format (PNG always seems to be premultiplied, webp isn't, etc.). I can't figure out a way to disable premultiplication or unpremultiply using sharp, so I was wondering if there was a way to handle premultiplied images within rgbaToThumbHash or process it myself before passing it to rgbaToThumbHash?
I'm using
sharpto resize the images for use withthumbhashwith user uploaded images like soI noticed that
sharpis outputting premultiplied images depending on the import format (PNG always seems to be premultiplied, webp isn't, etc.). I can't figure out a way to disable premultiplication or unpremultiply using sharp, so I was wondering if there was a way to handle premultiplied images withinrgbaToThumbHashor process it myself before passing it torgbaToThumbHash?