nodejs sharp change image to multiple sizes

Solutions on MaxInterview for nodejs sharp change image to multiple sizes by the best coders in the world

showing results for - "nodejs sharp change image to multiple sizes"
Cassius
26 Sep 2016
1// Sharp and FS module needed.
2;(async function(){
3	let imgBuffer = await sharp("./myimage.jpg").toBuffer()
4    let thumbnail = await sharp(imgBuffer).resize(100, 100).toBuffer()
5    let image = await sharp(imgBuffer).resize(1600, 900).toBuffer()
6    fs.writeFile("./thumbnail.jpg", thumbnail, err => {
7    	if(err) console.log(err)
8    })
9    fs.writeFile("./image.jpg", thumbnail, err => {
10      if(err) console.log(err)
11    })
12})