Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
37f4d56
Allow Figure_To_Pdf.py to run without omero
will-moore Feb 23, 2026
f309995
Add local pilfonts to scripts folder
will-moore Feb 23, 2026
1c7ff8d
revert removing omero-web requirement
will-moore Feb 23, 2026
28f3988
Add outputPathName option for standalone export script
will-moore Mar 4, 2026
1af65fb
Update README with standalone export script info
will-moore Mar 4, 2026
90e2961
Merge remote-tracking branch 'origin/master' into standalone_python_s…
will-moore Mar 17, 2026
d7b6b60
pip install [export] to include script dependencies, or [omero] for o…
will-moore Mar 4, 2026
6682109
Add __init__.py files to make figure_scripts into importable package
will-moore Mar 6, 2026
e6fc213
Add figure_export cli command
will-moore Mar 17, 2026
7f1f623
Add fsspec[http] to export dependencies
will-moore Mar 17, 2026
fe95184
Update README with export instructions
will-moore Mar 17, 2026
0affd4b
Flake8 fixes and add copyright to cli.py
will-moore Mar 18, 2026
4deda5b
Add NB: to figure export in README
will-moore Mar 18, 2026
03bd800
Add 'markdown' to export dependencies
will-moore Mar 18, 2026
0fbdafd
flake8 fix
will-moore Mar 23, 2026
5e455c6
figure export command checks for output file exists
will-moore Mar 23, 2026
96624c7
Ignore luts for OME-Zarr images in export script
will-moore Mar 24, 2026
d629a36
Add note to README about lack of LUTs support for figure export
will-moore Mar 24, 2026
10b6914
Update README.rst
will-moore Mar 24, 2026
28e72e5
Use grey instead of LUT for colorbar if no conn
will-moore Mar 24, 2026
254b60a
Fix: Zarr rendering ignores inactive channels
will-moore Mar 24, 2026
ab007ae
Remove blank line in README
will-moore Mar 24, 2026
8453017
flake8 fix
will-moore Mar 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 38 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,37 @@ Optional: To change the maximum active channel count from the default of 10:
Now restart OMERO.web as normal.


Enabling figure export
----------------------
Enabling figure export from OMERO
---------------------------------

This section assumes that an OMERO.server is already installed.

Figures can be exported as PDF or TIFF files using a script that runs on the OMERO.server. This script needs to be uploaded to the OMERO.server and its dependencies
installed in the OMERO.server virtual environment.

The script can be uploaded using two alternative workflows, both of which require you to have the correct admin privileges.
To find where OMERO.figure has been installed using pip, run:
The script can be uploaded using various workflows, all of which require you to have the correct admin privileges.

*Option 1*: Log in to the webclient as an Admin and open the OMERO.figure app. If the OMERO script is not found or is not up to date, you will
see a warning message with a button to upload the script. Click the button to upload the script from the OMERO.figure app.

*Option 2*: Upload the script from the installation directory. To find where OMERO.figure has been installed using pip, run:

::

$ pip show omero-figure

The command will display the absolute path to the directory where the application is installed e.g. ``~/<virtualenv_name>/lib/python3.6/site-packages``. Go to that directory.

*Option 1*: Connect to the OMERO server and upload the script via the CLI. It is important to be in the correct directory when uploading so that the script is uploaded with the full path: ``omero/figure_scripts/Figure_To_Pdf.py``:
Connect to the OMERO server and upload the script via the CLI. It is important to be in the correct directory when uploading so that the script is uploaded with the full path: ``omero/figure_scripts/Figure_To_Pdf.py``:

::

$ cd omero_figure/scripts
$ omero script upload omero/figure_scripts/Figure_To_Pdf.py --official

*Option 2*: Alternatively, before starting the OMERO.server, copy the script from the figure install
*Option 3*: Alternatively, before starting the OMERO.server, copy the script from the figure install
``/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py`` to the OMERO.server ``path/to/OMERO.server/lib/scripts/omero/figure_scripts``. Then restart the OMERO.server.

*Option 3*: Upload the script through the OMERO web interface: For this, log into your OMERO web interface as admin, select the scripts icon and click on the "Upload Script" button.
Select the ``Figure_To_Pdf.py`` script from the directory where you copied it to locally and upload it into the directory ``omero/figure_scripts``.

Now install the script's dependencies:


Expand All @@ -117,6 +118,34 @@ Now install the script's dependencies:

$ pip install markdown


Run Figure export locally
-------------------------

If your figure contains only OME-Zarr images (no images from OMERO), then
the export script can be run locally to convert a figure JSON file to PDF or TIFF.
NB: the OME-Zarr URLs must be accessible from the machine where the export script is run.
NB: channel LUTs are not currently supported when rendering OME-Zarr images for PDF or TIFFs.
Any LUTs will be rendered with white color.

Download the figure JSON (File > Save, in the standalone app) then install the export script.
Here, we create a new conda environment and install the export script:

::

$ conda create --name figure_export python=3.12
$ conda activate figure_export
$ pip install "omero-figure[export]"

To export the figure as PDF or TIFF, run the script with the path to the figure JSON and the output file path as arguments:
Use the ``.pdf`` extension for PDF export and ``.tiff`` for TIFF export. This example exports the
downloaded `figure_json/my_figure.json` to `my_figure.pdf` in the current directory:

::

$ figure_export figure_json/my_figure.json my_figure.pdf


Upgrading OMERO.figure
----------------------

Expand Down
63 changes: 63 additions & 0 deletions omero_figure/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# Copyright (c) 2014-2026 University of Dundee.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import argparse
import os

from omero_figure.scripts.omero.figure_scripts.Figure_To_Pdf \
import export_figure


def figure_export() -> None:
parser = argparse.ArgumentParser(
prog="figure_export",
description="Export an OMERO Figure file.",
)
parser.add_argument("input", type=str, help="Path to the input file")
parser.add_argument("output", type=str, help="Path to the output file")

args = parser.parse_args()
output_path = args.output
print(f"input: {args.input}")
print(f"output: {args.output}")

if os.path.exists(output_path):
print(f"Output file {output_path} already exists; Exiting.")
return

# open and read the input file
with open(args.input, 'r') as f:
figure_json = f.read()

fext = output_path.split('.')[-1].lower()
file_type = "TIFF" if fext in ['tif', 'tiff'] else "PDF"

script_args = {
"Figure_JSON": figure_json,
"outputPathName": output_path,
"Export_Option": file_type,
# TODO: Fix URL
"Webclient_URI": "http://localhost:8080/"
}

export_figure(None, script_args)

print("Figure export completed.")


if __name__ == "__main__":
figure_export()
Empty file.
Empty file.
Loading
Loading