'How to write a text + emojis on an background image with node js
This is a very unspecific question, but I couldn't find any reasonable help in the internet to complete this project on my on, so I thought here may be somebody who could help me.
I would like to print text (with emojis in it) on a background image with nodejs.
So I'm able to convert text to an image with text-to-image or text2png. I'm also able to convert an emoji to image data. But I haven't found a way to print text on an existing (background) image AND even add the emoji image at the right position in between the text.
If you have a solution in an other language for example python, that would be okay too. Then I would only need to get the text from nodes to python, which should not be too complicated.
Solution 1:[1]
Interesting that no one has answered this. I am trying to find a solution for the exact same need (minus the emoji :))
If you can do text to image, then I just found an article that shows how to composite two images using jimp. This seems like it would meet your needs. Providing text-to-image will save with transparent background.
I am going to try both these steps and I'll get back to you.
FOLLOW UP: There is "add-text-to-image". It's lightweight. Although it's poorly documented, I had to look at the source to get the parameters available.
JIMP lets you add text 'out of the box' and composite images, so you could do your text and add your emoji.
Hope that helps.
Solution 2:[2]
Using Jimp is a decent solution for writing a text on an image. But, the only limitation of using this package is that it only supports bitmap fonts. There is a function that helps to add your font.
Jimp.loadFont(pathOrURL)
The Emoji's availability depends on the font.
There is an alternative package that can be useful : https://www.npmjs.com/package/ultimate-text-to-image
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Wyck |
Solution 2 | sakigo |