user773737
user773737

Reputation:

How to convert filetype using GraphicsMagick for node.js

How do you "Convert" a file from one type to another using gm? (e.g .png > .jpg)

I found this but it doesn't seem that the node.js version has the same method:

Upvotes: 2

Views: 8779

Answers (1)

aembke
aembke

Reputation: 2649

You'll need to change the format of the output file.

var writeStream = fs.createWriteStream("output.jpg");
gm("img.png").setFormat("jpg").write(writeStream, function(error){
    console.log("Finished saving", error);
});

http://aheckmann.github.io/gm/docs.html#setformat

Upvotes: 10

Related Questions