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

201
Visualizações
Create an image with my initials using TypeScript and not 3rd party packages

I am using Node.js 14.18.1 and need to create an image, jpeg, with my initials using TypeScript, without the use of any 3rd party packages, like canvas.

I have performed this task using canvas, but it doesn't deploy well across multiple Operating Systems in my environment.

Any snippets would be appreciated.

For reference, here is the function I created using the canvas package from the npm registry:

const generateAvatar = ({ text, foregroundColor = 'white', backgroundColor = '#041c2c', height = 42, width = 42 }: {
  text: string,
  foregroundColor?: string,
  backgroundColor?: string,
  height?: number,
  width?: number
}): Buffer => {
  const canvas = createCanvas(width, height);
  const context = canvas.getContext('2d');

  // Draw background
  context.fillStyle = backgroundColor;
  context.fillRect(0, 0, canvas.width, canvas.height);

  // Draw text
  context.font = "1em Arial";
  context.fillStyle = foregroundColor;
  context.textAlign = "center";
  context.textBaseline = "middle";
  context.fillText(text, canvas.width / 2, canvas.height / 2);

  const buffer = canvas.toBuffer("image/jpeg");

  return buffer;
}
about 4 years ago · Santiago Gelvez
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