How to convert canvas to image file like PNG or JPG etc?

I am working with LVGL examples lv_ex_canvas_1.c file. How to convert output canvas to image file like PNG or JPG?

Maybe you want to take a look here.
As far as I can see, lodepng.c contains also a function lodepng_save_file.
But I don’t know whether this belongs to lvgl 8 only, or is also available with the old lvgl 7.