1

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.

here is my code

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);
});

it is giving error at this argument

'-set','option:compose:args -5x-5 ','-composite'
Manish Mittal
  • 207
  • 2
  • 10

1 Answers1

2

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);
});
emcconville
  • 23,800
  • 4
  • 50
  • 66