Home

Awesome

developer chat

ImageJ Server

This is a RESTful image server backed by ImageJ.

To provide easy-to-use and highly reusable image processing functionalities is a central goal of ImageJ. As a result, the components of ImageJ are modular, to make them easily accessible from other Java programs. However, for programs written in other languages besides Java, the interaction becomes complicated. In order to mitigate this problem, this RESTful image server is offered as a universal interfacing layer.

See the Rationale page of this repository's wiki for a longer discussion of cross-language integration and interoperability.

This is currently only a prototype! Testing needed!

Launching

The server can run with a graphical display, or in headless mode.

There are several ways to invoke the server:

<details><summary><b>If ImageJ is already running</b></summary>

You must enable the Server update site first.

</details> <details><summary><b>Launch via jgo</b></summary>

The jgo launcher makes it easy to launch the ImageJ Server. No need to explicitly clone the repository or download any JARs.

After installing jgo, add the following stanza to your ~/.jgorc file:

[repositories]
imagej.public = https://maven.imagej.net/content/groups/public

Then invoke the server with a graphical display as follows:

jgo net.imagej:imagej-server

Or in headless mode:

jgo -Djava.awt.headless=true net.imagej:imagej-server
</details> <details><summary><b>Launch from CLI via Maven</b></summary>

Clone this repository. Then start the server from the CLI in headless mode:

mvn -Pexec
</details> <details><summary><b>Launch from IDE</b></summary>

Clone this repository, import the project, then run the class net.imagej.server.Main. The server will launch in headless mode.

</details> <details><summary><b>Launch via the ImageJ Launcher</b></summary>

Enable the Server update site.

Then launch ImageJ with a graphical display:

./ImageJ --server

Or in headless mode:

./ImageJ --server --headless

See also the ImageJ Launcher documentation.

</details> <details><summary><b>Including additional plugins</b></summary>

If you want to make additional ImageJ plugins (e.g. plugins from Fiji) available remotely, you can include the additional components on the runtime classpath.

One easy way is via the jgo-based launch mechanism with the + syntax. For example:

jgo sc.fiji:fiji+net.imagej:image-server

Another way is make your own Maven project depending on net.imagej:imagej-server and other things, with a main entry point that invokes net.imagej.server.Main.main(String[]).

</details>

Usage

Python Client

The pyimagej module includes a Python wrapper for the web API.

Postman Collection

A collection of sample API calls to imagej-server using Postman.

Web client with GUI

Installation

Compilation and execution (development)

APIs

Returns a list of modules. By default, imagej-server exposes its API at localhost:8080, which will be used throughout this documentation.

$ curl localhost:8080/modules

Returns detailed information of a module specified by {id}. Notice that {id} could contain special characters such as dollar sign ($), which needs to be escaped when using cURL.

$ curl localhost:8080/modules/'command:net.imagej.ops.math.PrimitiveMath$IntegerAdd'

Executes a module with with JSON inputs. Use the module details to determine the correct input keys. The optional query parameter process determines if the execution should be pre/post processed.

$ curl -XPOST -H "Content-Type: application/json" -d '{"a":1,"b":3}' \
> localhost:8080/modules/'command:net.imagej.ops.math.PrimitiveMath$IntegerAdd'?process=false
{"result":4}

Lists all object IDs available on imagej-server.

$ curl localhost:8080/objects

Shows the information of an object.

$ curl localhost:8080/objects/object:1234567890abcdef
{"class":"net.imagej.DefaultDataset","created_at":"Sun Jan 01 00:00:00 CST 2017"}

Delete one object from imagej-server.

$ curl -XDELETE localhost:8080/objects/object:1234567890abcdef

Uploads a file to server. A 16-bit lowercase alphanumeric ID prefixed with object: will be returned as a JSON string. The ID can be used in module execution to represent the file. Currently only supports uploading images and tables in text. An optional query parameter type could be provided as hint to file type. If it is empty, filename would be used for guessing.

$ curl -F "file=@src/test/resources/imgs/about4.tif" localhost:8080/objects/upload
{"id":"object:0123456789abcdef"}

Download an object in some specific format from the server. Optional query parameters will be used for configuration depending on the type of the object.

$ curl localhost:8080/objects/object:0123456789abcdef/png

Stop the imagej-server gracefully without shutting down the imagej runtime.

curl -XDELETE localhost:8080/admin/stop

Notes and memo