I am trying to pipe data from a stream into a child process.
var gm = spawn( 'gm convert - -thumbnail 220x165^ -gravity center -extent 220x165 thumb.jpg' );
var rs = fs.createReadStream( 'cow.jpg' );
rs.pipe( gm.stdin )
Do I need to call end on gm for it to work? Also in my real code I am getting the stream from a database.
Example of how to stream a request into imagemagick:
var image = request.get(req.params.url);
var size = req.params.size.split('x');
var args = ['-', '-thumbnail', req.params.size + '^', '-gravity', 'center', '-extent', req.params.size, '-' ];
var convert = spawn('convert', args);
image.pipe(convert.stdin);
convert.stdout.pipe(res);
Great talk about this: http://vimeo.com/43380478
And the source code: https://github.com/felixge/rebel-resize
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With