nodejs Sharp: transparent into white
On version ^0.23
you can use flatten(options)
as api document here: https://sharp.readthedocs.io/en/stable/api-operation/#flatten
sharp('input.png').flatten({ background: { r: 255, g: 255, b: 255 } })
by the document, we should do the way as Msalam suggest but unluckily that is not enough. I figured out We should add .flatten(true) before ".resize(...)" to make it work correctly.
from the sharp documentation as it states that you can use the background for color manipulations and it states that
The default background is {r: 0, g: 0, b: 0, alpha: 1}, black without transparency.
so inorder to get white simply use
.background({r: 255, g: 255, b: 255, alpha: 1})