Reputation:
I read the docs: https://github.com/oliver-moran/jimp
But could not find how to convert an image from png to jpg.
I must have missed something obvious.
Using jimp on my server with Node.js.
Here's my code:
image.scaleToFit(500, 500, Jimp.RESIZE_BICUBIC).quality(60).write("./public/images/uploads/thumb"+req.file.filename, function(err) {
Upvotes: 3
Views: 8062
Reputation: 1519
What is wrong with the example from their documentation? It kind of does what you want - converts png to jpg.
var Jimp = require("jimp");
// open a file called "lenna.png"
Jimp.read("lenna.png", function (err, lenna) {
if (err) throw err;
lenna.resize(256, 256) // resize
.quality(60) // set JPEG quality
.greyscale() // set greyscale
.write("lena-small-bw.jpg"); // save
});
Upvotes: 10