i'm trying composite multiple images single stream piped response. i'm using node.js , graphicsmagick node @ https://github.com/aheckmann/gm.
if i'm compositing 2 images stream works fine , example shows two/thirds of final composite expected. here code:
app.get('/call_2image_stream', function(req, res){ res.writehead(200, {'content-type' : 'image/png'}); var path = (__dirname + '/test_folder/happy_right.png'); var path2 = (__dirname + '/test_folder/happy_left.png'); gm(path) .composite(path2) .stream('png') .pipe(res); })
but when try , composite 3 images doesn't fill in bottom part of picture correctly intended. code this:
app.get('/call_3image_stream', function(req, res){ res.writehead(200, {'content-type' : 'image/png'}); var path = (__dirname + '/test_folder/happy_bottom.png'); var path2 = (__dirname + '/test_folder/happy_right.png'); var path3 = (__dirname + '/test_folder/happy_left.png'); gm(path) .composite(path2) .composite(path3) .stream('png') .pipe(res); })
figured out great answer write here: https://stackoverflow.com/a/20611669/4447761 shout out ryan wu!
here final code
app.get('/final_code', function(req, res){ res.writehead(200, {'content-type' : 'image/png'}); gm() .in('-page', '+0+0') .in(__dirname + '/test_folder/happy_right.png') .in('-page', '+0+0') .in(__dirname + '/test_folder/happy_left.png') .in('-page', '+0+0') .in(__dirname + '/test_folder/happy_bottom.png') .mosaic() .stream('png') .pipe(res); })
Comments
Post a Comment