Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

264
Visualizações
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 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda