• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

224
Views
Node Jimp - How to add a text with a squared background

I need to add a text on a image using Jimp node module. But sometimes it get confused with the image. For example: Black text hover an image with black on itself.

So i need to insert a white square and write with black inside of it.

Didnt find it on the documentation of Jimp.

My actual code:

await  Jimp2.read(nomeArquivo)
    .then(function (image) {
        
        loadedImage = image;
        return Jimp2.loadFont(Jimp2.FONT_SANS_16_BLACK);
    })
    .then(function (font) {
        loadedImage.print(font, 45, 45,'car' ,450 , (err, image, { x, y }) => {
                    image.print(font, 45, y + 4, {
                        text: 'this car is ok',
                        alignmentX: Jimp2.HORIZONTAL_ALIGN_CENTER,
                        alignmentY: Jimp2.VERTICAL_ALIGN_MIDDLE
                    },450);
                } )
                .write(nomeArquivo);
    })
    .catch(function (err) {
        console.error(err);
    });

This writes the text hover the image, but not the square.

Thanks!

about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error