使用Node.js和gm合并两张图片

4
我希望使用node.js和gm for node合并2个图像。实际上,我想将一个较小的图像放在坐标x,y上的较大的图像上。
我已经使用append()做了一些工作,但我无法选择将第二个图像放在第一个图像上方。
以下是我的js代码:
gm('img/vector/test.svg').append('img/base/test.png').write('img/final/test.png', function(err, stdout, stderr, command){
            if (err){
                console.log('image conversion error!'); 
                console.log(err); 
                console.log(command);    
            }else{ 
                console.log('image converted with command :'); 
                console.log(command);
            } 
        })
1个回答

1
"This option creates a single image where the images in the original set are stacked top-to-bottom" 说gm doc
通常我会说看看montage,但是这个节点模块似乎不支持...

5
我最终使用montage找到了一个解决方法: gm('img/base/'+baseFileName+'.png') .subCommand('montage') .texture('img/vector/svg-'+scorePercent+'.svg') .geometry(81, 81) .font('Arial', 18) .fill(textColor) .drawText(textPos, 60, textLabel) .write('img/final/'+baseFileName+'.png', function(...) - Seb

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接