Suggestions for Node text to image library

The Tidbyt API looks incredibly easy to use, but I’m struggling with finding a light weight (non-binary requiring) Node library to convert text to images. Does anyone have a simple library for that they could suggest?

For my node tidbyt apps, I am using bdfparser:

const { $Font } = require('bdfparser');
const getline = require('readlineiter');
const font = await $Font(getline('./tb-8.bdf'));

Then I draw that to a Canvas element and render that to a gif (or you could do a webp)

const { createCanvas } = require('canvas');
const canvas = createCanvas(width, height);
const context = canvas.getContext('2d');
const text = font.draw('Some Text', {linelimit: 64});
text.draw2canvas(context, {'1': 'white'});

Then you just need to grab the fonts that the Tidbyt team makes available for pixlet

This has worked well for me for 2 different node tidbyt apps.

Thank you. Do you mind if I also ask - what can cause “encoding image for device: Error assembling animation”? I’m getting that trying to post a simple GIF.

Sorry, not sure. What GIF encoding library are you using? I’ve been using gifencoder:

I haven’t seen that specific error in my apps.

Also, I’ve been using this library to communicate to tidbyt (and not pixlet).

For me, pixlet seemed to add more complexity than what I was looking for, so I didn’t end up using it.

I tried that library, but noted that installationId was marked optional, but required. I’m trying to send just a message, not install an app. For the GIF, I wasn’t actually generating it, but ‘cheating’ by using placeholder.com. Specifically this: https://via.placeholder.com/64x32.gif?text=Ray

To be clear, I’m not trying to use the URL, but I fetch the arraybuffer and convert to base64. (That’s something else - it was a bit hard to tell from the docs if the binary should be passed as is, or converted to b64 first.)

I haven’t used the message feature, but for apps, the installationId is just whatever ID you come up with. I just make it a single string of my app name. Then I use that tidbyt library to push a buffer with the GIF data.

For non-public apps, they are really just images anyway. You can’t set configuration options yet (like schedules or other settings), but you can push the image into the background of the current rotation. I think you’ll probably want an app with an installationId eventually.

Ok -I guess I was worried about my installationId showing up in the mobile app, and it doesn’t. I can confirm the npm library works well, and now it’s placeholder.com that is throwing fits a few times so I need to replace it with bdfparser.

Last question - I promise. And thank you for the help so far. Do you have a full example of your use of bdfparser you can share? Just the link I mean.

I actually got it working quite quickly - but I’d still love to see your example too. Thank you!

I’m glad you got it working! I actually don’t have my code on GitHub, so I can’t send a link. What I have above is basically it, without the GIF rendering and Tidbyt library pieces. Sorry!