如何在节点imagemagick模块转换函数中传递多个参数 [英] How to pass multiple arguments in node imagemagick module convert function

查看:140
本文介绍了如何在节点imagemagick模块转换函数中传递多个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用节点imagemagick模块的转换函数
当我通过终端使用此命令时它工作正常

I am using node imagemagick module's convert function When I am using this command through terminal then it is working fine

convert /home/manish/Downloads/new_images/slim_fit_double_breasted_coat_base.png /home/manish/Desktop/Medium-Vichy-9274-Fabric-Gauloise-058.jpg \( -clone 0 -auto-level \) \( -clone 1 -clone 0 -alpha set -virtual-pixel transparent -compose displace -set option:compose:args -5x-5 -composite \)   fabric2.png

但是当我在节点模块中传递相同的命令时,它没有给出预期的结果。

but when I am passing the same command in node module then it is not giving expected result.

这是我的代码

var im = require('imagemagick');


im.convert(['/home/manish/Downloads/new_images/slim_fit_double_breasted_coat_base.png','/home/manish/Desktop/green-flower-lavender-eye-pillow-fabric.jpg', '-clone', '0', '-auto-level','-clone','1','-clone','0','-alpha' , 'set' ,'-virtual-pixel','transparent','-compose','displace','-set','option:compose:args -5x-5 ','-composite','fabricted111.png'],
    function (err, stdout) {
        if (err) throw err;
        console.log('stdout:', stdout);
});

它在此参数中给出错误

'-set','option:compose:args -5x-5 ','-composite'


推荐答案

看起来代码丢失 image-stack operator \(... \),因此您的代码与CLI命令不匹配。

Looks like your code is missing image-stack operator \( ... \), so your code does not match the CLI command.

command = ['/home/manish/Downloads/new_images/slim_fit_double_breasted_coat_base.png',
           '/home/manish/Desktop/green-flower-lavender-eye-pillow-fabric.jpg',
           '\\(',          // <--- missing (
           '-clone',
           '0',
           '-auto-level',
           '\\)',          // <--- missing )
           '\\(',          // <--- missing (
           '-clone',
           '1',
           '-clone',
           '0',
           '-alpha',
           'set',
           '-virtual-pixel',
           'transparent',
           '-compose',
           'displace',
           '-set',
           'option:compose:args -5x-5 ',
           '-composite',
           '\\)',          // <--- missing )
           'fabricted111.png'];
im.convert(command,
    function (err, stdout) {
        if (err) throw err;
        console.log('stdout:', stdout);
});

这篇关于如何在节点imagemagick模块转换函数中传递多个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆