Answer the question
In order to leave comments, you need to log in
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);
});
Answer the question
In order to leave comments, you need to log in
> 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'], ....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question