Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda