Skip to content

Instantly share code, notes, and snippets.

@alfredwesterveld
Created March 28, 2016 20:03
Show Gist options
  • Select an option

  • Save alfredwesterveld/1069b1a87877bcfba0a7 to your computer and use it in GitHub Desktop.

Select an option

Save alfredwesterveld/1069b1a87877bcfba0a7 to your computer and use it in GitHub Desktop.
var sharp = require('sharp');
var fs = require('fs');
// Read image data from readableStream, resize and write image data to writableStream
for (var i=0; i < 100; i++) {
var rs = fs.createReadStream('./direct.png');
var ws = fs.createWriteStream(`./thumbs/direct-thumb-${i}.png`);
rs.pipe(sharp()
.resize(437, 315)
.on('error', function(err) {
console.log(err);
})).pipe(ws);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment