Use python to export figures from omero


How can I export omero.figures using python? I want to loop through my figures and do a tiff download. I can connect and generate a list of figures using something like this I found in an old forum and the help docs:

> import omero.clients
> from omero.gateway import BlitzGateway
> with BlitzGateway("username", "password", host='', port=4064, secure=False) as conn:
>     for f in conn.getObjects("FileAnnotation", attributes={"ns":"omero.web.figure.json"}):
>         print(f.getId(), f.getFile().getName())

I can figure out how to loop through the figures, but how do I trigger an export? I’d like have them exported somewhere on the same omero server, not to my desktop.

thanks for your help and time! -John

Hi John,

You have to use the OMERO.figure export script in the same way that figure app does, since I’m afraid the figure generation code is not runnable separately from the script logic.

There’s some code to show you how to do this at

The getObjects() example there also filters figures by owner.

NB: currently that code only exports a single figure, so you’ll have to put the code into your loop, and make sure you don’t have multiple figures with the same name as they’ll overwrite each other when downloading.

Hope that helps,


Huge! Works great and thank you for all the extra code. Very helpful.

I did get a warning at the end:
!! 12/14/20 12:50:30.986 error: communicator not destroyed during global destruction.

I also see the commented code regarding joining an existing session. Is the ‘conn’ created by this script still floating around somewhere?


Hi John,

Yes, good catch! I was missing a conn.close() at the end.
That should also fix the warning that you’re seeing.