The config file is turned into a dictionary of dictionaries at startup, e.g.:
[loris.Loris]
cache_dp=/tmp/loris/cache
tmp_dp=/tmp/loris
...
[resolver.Resolver]
src_img_root=/usr/local/share/images
yields
config = {
'loris.Loris': {
'cache_dp' : '/tmp/loris/cache',
'tmp_dp' : '/tmp/loris'
},
'resolver.Resolver' {
'src_img_root' : '/usr/local/share/images'
}
}
which is then available in the config
attribute of the application. The sub-dictionaries are then used to configure other objects, by passing the values of individual entries or just the entire dict, depending on how complex the situation is. Generally, the naming conventions and principals behind how this is intended to work should be clear.
N.B.: When developing or extending, i.e., instantiating the application instance in debug mode (by calling webapp.create_app(debug=True)
), some properties in etc/loris.conf
are overridden in the create_app
function. This is done so that we can calculate some locations based on the application directory. Therefore, if you need to add additional configuration, e.g. in your resolver or transformations, you may need to add/set them in two places if you want an option to be different when developing/running tests: in etc/loris2.conf
and in the first if
block of webapp.create_app
.
To run all of the tests, from the /loris
directory (not /loris/loris
) just run ./test.py
. If you just want to run the tests for a single module, do, e.g. python -m unittest -v tests.parameters_t
from the same dir as above.
loris/webapp.py
is executable, and will start a development server at localhost:5004. From there you can work with the images that are included for testing by plugging any of these into the identifier slot:
01%2F02%2F0001.jp2
01%2F03%2F0001.jpg
01%2F02%2Fgray.jp2
01%2F04%2F0001.tif
47102787.jp2
# use this one to make sure color profile mapping is working.
Loris is designed to make it possible for you to implement image transformations using any libraries or utilities you choose. The transformers are loaded dynamically at startup, and are configured in etc/loris2.conf
. See transforms.py
for details. Transformers for JPEG, TIFF, GIF, and JP2 (JP2 as long as you provide the Kakadu dependencies) using Pillow are provided.
More about this. Every _AbstractTransformer
implementation must implement a transform()
method that receives the path to the source file (src_fp
), the path to where the output file should go (target_fp
), and an instance of an img.ImageRequest
object. This object should contain all of the attributes you could ever possbily need for working with an image library. See img.ImageRequest.__slots__
for details.
[transforms][[{fmt}]]
is the naming convention for of these sections in etc/loris2.conf
. This MUST be followed, and {fmy} MUST be one of the extension strings listed in the IIIF Image API specification.
Every section requires an impl
key, and any other options provided will be automatically be available to the impl in its config dictionary.
At least for now, all implementation must be in (or aliased in) the transforms module.