Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 302
spooky Avatar asked Dec 17 '13 20:12

spooky


People also ask

What is stream PassThrough ()?

PassThrough. This Stream is a trivial implementation of a Transform stream that simply passes the input bytes across to the output. This is mainly for testing and some other trivial use cases. Here is an example of Passthrough Stream where it is piping from readable stream to writable stream.

What is sharp node JS?

sharp is a popular Node. js image processing library that supports various image file formats, such as JPEG, PNG, GIF, WebP, AVIF, SVG and TIFF. In this tutorial, you'll use sharp to read an image and extract its metadata, resize, change an image format, and compress an image.

What does buffer from do?

The Buffer. from() method is used to create a new buffer containing the specified string, array or buffer.


1 Answers

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).

like image 182
ptr Avatar answered Sep 27 '22 20:09

ptr