A
A
Alexander Knyazev2016-03-24 21:24:12
JavaScript
Alexander Knyazev, 2016-03-24 21:24:12

Working with Imagemagick in Node. How to convert images to video/gif?

The task is to convert a bunch of images to video or gif using the npm module imagemagick.
Using the Imagemagick console application, this could be done with the following command:
convert *.jpg myfilm.mp4
I am now trying to do this through node. One image is converted like this:

var im = require('imagemagick');
var inputPath = '1.png';
var outputPath = '1.gif';
var width = 700; // output width in pixels

im.convert([inputPath, width, outputPath], function(err, stdout, stderr) {
   console.log(err);
});

How can I tell the convert method here to take multiple images and convert them to a single gif?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Erokhin, 2016-03-25
@alexandrknyazev13071995

> convert *.jpg myfilm.mp4
When you run this in the console, the command shell does the following for you: it sees the pattern *.jpg, looks for all files that match this pattern, for example 1.jpg, 2.jpg, 3.jpg, and calls the command already as the
Shell does it for you, and in js you have to get the list of argument files yourself, something like this

im.convert(['1.jpg', '2.jpg', '3.jpg', 'myfilm.mp4'], ....

S
sim3x, 2016-03-25
@sim3x

https://trac.ffmpeg.org/wiki/Create%20a%20video%20...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question