Best way to convert text/string to image in Node.JS

spooky picture spooky · Dec 17, 2013 · Viewed 8.9k times · Source

I want to convert my text string into an image with basic font. I would like to do this on Node server. Are there any libraries that you might have worked with? Any help is greatly appreciated.

Answer

ptr picture ptr · Dec 17, 2013

Try node-canvas. If you have experience working with html5's canvas element on the client side, you can do it with this on the server side as well - and there is the .toDataURL method for exporting the drawing into a data-url blob (which contains basically a base64-ed png image).