Search code examples
node.jsimage-processingserver-side

How to render/generate image according to text/string in nodejs?


How can i generate an image of a string that has:

  • a size in px
  • embossed effect of the letters in the image
  • a font
  • a color
  • and other less important stuff that i think i can figure out once i achieve whats above like:
    • rotation of text
    • drop shadow

basically the user will send a request on how he wants his image to be.

but when i receive the request how should i make use of nodejs to render a png or a base64 url to send it back to the user. is there any libraries or way to achieve this.

i did some previous research and it doesn't seem like there is a frameworks that helps render text with a font and text style like emboss


Solution

  • You can try node canvas implementation: https://github.com/Automattic/node-canvas

    Basically you can "draw" anything you want like if you'd be using browser js canvas, but some things may be different