I'm trying to edit my images on my node.js application working on the server-side. At this moment, I've successfully added text over my image. I would like to place a green rectangle at the top left corner over this image and I tried this method:
Jimp.read(`borderTop.png`, function (err, top) {
top.rotate(45);
Jimp.read(`img.png`, function (err, image) {
if (err) console.log(err);
image.blit(top, 430, -250);
Jimp.loadFont(`${__dirname}/../public/fonts/*.fnt`).then(function (font) {
image.print(font, 315 - ((16 * 13 ) / 2), 0, "Hello, world!");
image.write(finalName, (err) => {
return cb(null, `img.png`);
});
});
});
});
This is working but it's removing part of my image that is under the border.
I tried:
.png
fileJIMP, also known as JavaScript Image Manipulation Program, is an image processing library for Node written in JavaScript with no other dependency. It allows the user to easily manipulate the and transform the images into any required shape, format, dimnesion or style.
Introduction. Jimp is a node module used to do image processing which is provided by the npm installer. The Jimp – Javascript Image Manipulation Program is a library written entirely in JavaScript for Node, without any external or native dependencies.
To make it work you have to use :
image.composite( src, x, y ); // composites another Jimp image over this image at x, y
from jimp doc
because image.blit()
is just deleting everything under your image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With