Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!