GUI already does this.
Need only use GUI/main.py export_json() and/or export_curr_slice_as_img() in CLI.
Preferably, these functions should be moved to some file in utils/ so that they can be accessed from both CLI and GUI.
As an aside, a lot of other code in CLI and GUI should be factored out to file(s) in utils/.