To do image resizing without ImageMagick with Node.js, we use the lwip
package.
To use it we write
require("lwip").open("image.jpg", (err, image) => {
image
.batch()
.scale(0.75)
.rotate(45, "white")
.crop(200)
.blur(5)
.writeFile("output.jpg", (err) => {
//...
});
});
to call open
to open image.jpg for resizing.
Then we call scale
to resize it to 75% its original size.
We rotate by 45 degrees clockwise with rotate
and fill the space with white.
Then we call crop
to crop it to 200px by 200px.
Next we call blur
to blur the image.
And we call writeFile
to write the modified image to output.jpg.
We can get errors from err
in the callback.