New image converter

Today the LVGL image converter website was switched to use my new JavaScript-based converter which runs directly in your browser, rather than the old PHP image converter which relied on server-side facilities as well. This improvement has been quite a while in the making and I’m pleased to have finally been able to complete it.

The new converter should be significantly more reliable at parsing images. In the past there have frequently been issues with image formats like indexed PNGs. These should now be handled correctly. In fact, any image which your browser can display should now work without issues with the converter, as it uses your browser’s built-in facilities to read the image.

Some other bonus features:

  • Big-endian image conversion (only works with “C array” format at the moment).
  • It is now possible to convert multiple images at once.
  • Attempting to convert larger images should no longer result in an out-of-memory error.

Please give it a try and be sure to let us know if you encounter any issues!

7 Likes

What do you recommend for batch conversions? I am currently using the php with a shell script.

There is no need to immediately change your workflow if the PHP converter is working for you.

That being said, I have just finished publishing the converter as a proper NPM module, so you should be able to install and use it as follows. You will need to have a relatively recent version of Node.js installed for this to work.

npm install -g lv_img_conv
npx lv_img_conv --help
npx lv_img_conv logo_lvgl.png -o myfile.c -c CF_TRUE_COLOR_ALPHA # convert logo_lvgl.png to myfile.c with true color alpha format

The help option lists all the possible color formats.

You should be able to adapt the last command to a shell script easily.

Thanks. I’ll try it out and compare the results.

Yesterday I tried with SVG images, it worked well! :rocket:

Just tried installing this as a npm module, but failed. Not sure how to make it work. Attached is a log of all the errors and appreciate some guidance.
error log.txt (92.1 KB)

I’m not a webdeveloper so I just copy pasted the log to ChatGPT and it told these:

This is a common build error related to the native dependency canvas when using node-gyp on Windows.


The actual issue:

Error: MSBuild.exe failed with exit code: 1

Most likely causes:

  1. node-canvas is not compatible yet with Node.js v23.x
    canvas often lags behind Node’s latest versions because it depends on native C++ bindings.
  2. Missing or incompatible Windows Build Tools
    You have Visual Studio Build Tools installed (MSBuild.exe is found) but it might not have:
  • The correct C++ workload
  • Windows SDK
  • Desktop development with C++ workload
  1. node-gyp v11 may not fully support Node.js v23 yet.

Solution

Use fnm to switch back to Node.js v20.x LTS for now:

fnm install 20
fnm use 20
npm rebuild

I hope it helps :crossed_fingers:

Thanks. The real issue turned out to be that certain Canvas dependencies like GTK and Cairo were missing. Finally able to install this with node 23.8.0

1 Like

Hey all!

So I tried using that online converter, and it appears to have given me wrong colours (kinda looked like a badly-parsed JPEG) when loaded and ran on an ST7789-backed display on ESP32-C3-SuperMini.

When I rolled my own converter (pixel-by-pixel direct LUT from RGB to RGB565 in PHP), the colours came out fine for the same PNG.

I never did do any LV_IMG_DECLARE in my code - seems to work just fine w/o it? Or is that my issue? I used an RGB/8 input image, and I’m using LVGL v9.5.

Can you share a photo about the screen and original + converted image?

When converting the binary bin file using the LVGLImage.py provided by the official LVGL, the problem shown in the figure appears on the screen

Sure.

2026-01-30__converter_output.zip (251.6 KB)

Just re-ran it all, to make sure.

The ZIP file includes both .c files (kadconverter is done by me, lvglconverter by the online tool), both photos, and the source .png for your analysis.

The PNG was produced with Photoshop CS6 on Windows – and the conversion was done on Windows under Brave Browser (if this matters… and considering it’s JS – it just might).

It seems like it’s an RGB565 byte swapping issue and some different rounding in the converters.

                   Byte 1 | Byte 2
                   R      G       B
LVGL:            01111 111|110 11111
LVGL swapped:    11011 111|011 11111
KAD:             11010 111|010 11110

So there is only one LSB difference in LVGL Swapped and KAD.

What you can do is

  • Use ./lvgl/scripts/LVGLImage.py path/to/bg_dickbutt_v1.png --ofmt C --cf RGB565_SWAPPED
  • Or use swap the the byte of the render image in your flush_cb. More info here
  • Make LVGL render in Swapped color format by calling lv_display_set_color_format(display, LV_COLOR_FORMAT_RGB565_SWAPPED); It’s recommended to use swapped images too, to make rendering faster.

Hi, please share to original image and the exact command you have used for LVGLImage.py

python LVGLImage.py --ofmt BIN --cf RGB565 --align 1 --compress NONE -o E:\new E:\images\face_image.png
face_image