0

I want to split input.gif into the files output0.png through output15.png. Works perfectly fine in the terminal when I use this:

convert -coalesce input.gif output%d.png

But now I need to automate this across hundreds of files in specific folders using gm and I can not figure out how to make it work. You are supposed to use in() and out() to handle arguments, but it only ever outputs a single file named output%d.png

Can anyone with experience about gm help?

This is my current try:

gm("input.gif")
    .in("-coalesce")
    .out("output%d.png")
    .stream("png", function (err, stdout, stderr) {
        // console.log(stdout)
        var writeStream = fs.createWriteStream("output%d.png");
        stdout.pipe(writeStream);
      });
SINCOS
  • 89
  • 6
  • Why are you even using Javascript? What OS are you using? – Mark Setchell Jun 26 '21 at 20:17
  • I'm using javascript because the goal is to create a website with a node backend that can combine and separate gifs. It's also the language I'm most familiar with. – SINCOS Jun 27 '21 at 21:12

0 Answers0