A little extension to image converter

Hi, it’s me again stealing your precious time.

The Image Converter. How about:
a) develop a nice, portable CMD line app to do it (Python? C?) I had a look at lv_utils repo, the current alternative is somewhat … Well.
b) the web version would be nice should it work in batch mode, ie.

  • accept multiple source image files
  • provide a name prefix field to name the c-source consts (for example - image name is “button_back.png”, prefix is “bm_” --> image descriptor would look like const lv_img_dsc_t bm_button_back = { …etc)
  • multiple images would be put to a single source file (“img_data.c” or similar) to be downloaded

Sorry for trouble,
-petri h

1 Like

I’m planning to rewrite the image converter in Node.js. (In fact, I’ve started, but there’s nothing of substance to show yet.)

I’ll do my best to implement the points you mentioned!


Oh, good to hear!

Then, is there something in Node.js that makes easier to do this kind of utility? I mean … if it was in C(++) or even Python, one could make an offline converter quite easily.

OK, I know nothing about Node.js and thus I’m somewhat afraid to bring all the necessary bricks to my linux installation. Maybe it all is because of my ignorance. Let’s see :relaxed:

It’s very easy to make it work on both the command line and the web when Node.js is used. This is what we did for the font converter.

1 Like

Hmm. Guess I have to pay a little attention to the “dark side” too. See, I have started with Z80 assembly some 10000 years ago, and consider C as an intelligent macro assembler :smile:

But I’m not beyond hope (I hope) - I’ve given a change to Python some time ago, and fell in love for instance in the unbearable easiness of it’s string manipulation. Maybe Node.js will blow my mind (the little that is left) for good?

Thanks and have a nice weekend!


Any news on this? Having converted dozens of little pictures using the web based converter I’d really appreciate a batch version. And a single source containing multiple images … Depending on environment, multiple sources can be a no-brainer - OR tedious manual adding of them all :stuck_out_tongue:

Unfortunately, I haven’t had much time to work on this. The current version I have can load images but can’t output files and has no UI yet.

If you’re familiar with shell scripts you can run the current converter offline in a script.

The same script could concatenate all of them into a file.

Well, I’m an old guy, but in order to keep my employer paying me for what I do it is good to learn something new every now and then. I’ll have a look (if I only have the time!), thanks!

I now have something of substance. At the moment it can only convert images in true color mode, however, adding the other modes should be straightforward, as the converter core is a copy-paste of the original PHP code by @kisvegabor (obviously tweaked to use JS syntax instead of PHP).

I’m planning to make this fully compatible with all image types first, then I will work on a web interface.

1 Like

Now all image types work except for the indexed images. I’m having trouble with these as I can’t find a JS library to replace the built-in PHP function which converts this.


That’s awesome!

I feel shame for the quality of that PHP code… :sweat_smile: I hope it didn’t hurt too much. :smiley:

If I recall correctly, we used RgbQuant in a project earlier. Maybe it helps.

I ended up using a derivative of that library. I have 8-bit indexing working - I just need to get the bitwise logic working for 1, 2, and 4-bit. Then I can start working on the web interface.

Great news! Two questions came to my mind:

  • Will the new converter support dithering?
  • Will it be able to handle alpha channel in the palette? (and in dithering)

Yes. Dithering for indexed images is handled by the library. Dithering for 16-bit images is handled by your existing code.

Yes; I believe so.

All of the image formats (true color, indexed, and alpha) are now compatible with the CLI version. The web interface is roughly 25% complete.

1 Like

Awesome! Can’t wait to try it!

I also needed to convert a bunch of file I made a python script to do it in batch mode with the help of the php offline script.

If anyone needs it it’s hosted here : https://github.com/Yohannfra/lvgl_batch_image_converter


Very useful, thank you!

The groundwork for this is in place now. Bulk conversion doesn’t work exactly as requested (it requires you to put the full name, not a prefix, and downloads multiple files) but it is a feature now.

See my second post for instructions on a more portable installation.