I need resize image to fixed size in Node.js through ImageMagick. Example: images 200x140, 500x200 and 130x100 converted to 100x50. The image must be stretched or compressed without aspect ratio and fill the entire space. I do this so:
var im = require('imagemagick');
var resize_options = {
srcPath: path,
dstPath: path,
width: 100,
height: 50
};
im.resize(resize_options, function (err) {
if (err) {
console.log(err);
res.end('Error!');
}
else {
res.end('Success!');
}
});
But image converten by only height, example - 1440x900 converted to 80x50 instead 100x50. What am I doing wrong?
replaceExact
method which only takes output size parameters, or if you can slip in an exclamation mark amongst options. Please read documentation forgm
on github - it covers this issue exactly. Noting theimagemagick
module is abandoned in favor ofgm
. If this solves your issue please post an answer describing how to do it. – traktor