Pipe stream to graphicsmagick/imagemagick child process

后端 未结 1 1297
北恋
北恋 2021-02-03 12:26

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\' );
va         


        
相关标签:
1条回答
  • 2021-02-03 12:55

    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

    0 讨论(0)
提交回复
热议问题