How to determine if a PNG Image Source is not empty

i’m looking for a solution to determine if a png image source is valid and shows an image. My task is to show a company label in a userlist, if the user has a company label, otherwise show a label with its name:

lv_obj_t *logo = lv_img_create(obj);
char src[50];
lv_img_set_src(logo,(void *) src);

how do i detect if the source path has no valid file and shows an empty image using the image object?


i solved this using lv_img_decoder_open and polling the image data as described in the docs:

    lv_res_t res = lv_img_decoder_open(&img_decoder, img_src, no_color, 0);
    if(res == LV_RES_OK && img_decoder.img_data) {
        // hide label if image data is present
        lv_obj_add_flag(entry->label1, LV_OBJ_FLAG_HIDDEN);