Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Lightning talk re: Loris <> for code4lib 2013.

Meet Loris

Loris is an Implementation of the IIIF (International Image Interoperability Framework) Image API specification. Loris is designed to work w/ JPEG2000 files, but this is not part of the spec.

IIIF defines a Syntax for accessing images:


and a bit of metadata about them:


One of the goals is to have a persistent and cool URI not just for the image but regions and other derivatives thereof, so that you can make statements about those regions or derivatives.

The Parts

identifier | region | size | rotation | quality


Loris ships w/ a simple ID resolver that just takes a slice of a filesystem path and resolves it to a file. This is isolated in and is designed to be changed to suit different environments.



Get the full image /full/full/0/native.jpg


Region can be specified by pixel or percent:



Again as percent:


or pixel (w,, w,h, or ,h):



Multiples of 90.



Can be native, color, grey or bitonal. Which are available (color or not) is available from info service.



Loris does jpg and png and the moment. The only feature missing from making this a IIIF level impl is that it won't return a jp2. You can define a default in config file, and use content negotiation rather than a file ext as well.

Ask for a png: /full/120,/0/native.png

Use the default: /full/120,/0/native

Use Conneg:

curl -v \
  -H "Accept: image/png" \
  ",/0/native" \
  -o /tmp/a.png


Basically just enough metadata to drive a UI.



Cache is built on the FS mirroring the path in the URI, so each request looks there first. We just use a cron to check that it's not bigger than we want, and clear out LRU files until the size is acceptable. A sample copy of the cron is in the code repo. It could be smarter if you needed it to be.


As expected, will send a 304 if client sends an If-Modified-Since header (and it hasn't been).


IIIF also defines a syntax for the HTTP message body when something goes wrong.

Obviously you get a 4xx/5xx as well.


Not much until last week! Chris Thatcher / OpenSeadragon Just added support for IIIF syntax.

Loris on Github

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment