Skip to content

Instantly share code, notes, and snippets.

@bootrino
Created August 30, 2018 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bootrino/7edfc6b2e5ee6142a786069d0ba2f72e to your computer and use it in GitHub Desktop.
Save bootrino/7edfc6b2e5ee6142a786069d0ba2f72e to your computer and use it in GitHub Desktop.
nodejs transform image with sharp
async function transformImage(dataBytes: any) {
//let convert = async(dataBytes: any) => sharp(dataBytes).background({r: 255, g: 255, b: 255, alpha: 0}).toFormat('png').toBuffer()
let convert = async(dataBytes: any) => sharp(dataBytes).toFormat('png').toBuffer()
dataBytes = await(convert(dataBytes))
return dataBytes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment