diff --git a/src/omv/modules/py_imageio.c b/src/omv/modules/py_imageio.c index 1773d87f9..efb4acb75 100644 --- a/src/omv/modules/py_imageio.c +++ b/src/omv/modules/py_imageio.c @@ -155,10 +155,6 @@ mp_obj_t py_imageio_read(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) } } - if (copy_to_fb) { - framebuffer_update_jpeg_buffer(); - } - if (0) { #if defined(IMLIB_ENABLE_IMAGE_FILE_IO) } else if (stream->type == IMAGE_IO_FILE_STREAM) { @@ -255,6 +251,10 @@ mp_obj_t py_imageio_read(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Invalid image stream")); } + if (copy_to_fb) { + framebuffer_update_jpeg_buffer(); + } + return py_image_from_struct(&image); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_imageio_read_obj, 1, py_imageio_read);