Source Images
The S3 key of any given file, minus the extension, is its IIIF ID. For example, if you want to access the image manifest for the file at abcdef.tif
, you would get https://.../iiif/2/abcdef/info.json
. If your key contains slashes, they must be URL-encoded: e.g., ab/cd/ef/gh.tif
would be at https://.../iiif/2/ab%2Fcd%2Fef%2Fgh/info.json
. (This limitation could easily be fixed by encoding only the necessary slashes in the incoming URL before handing it off to the IIIF processor, but that's beyond the scope of the demo.)
iiif-processor
can use any image format natively supported by libvips (opens in a new tab), including JPEG 2000 (.jp2
), but best results will come from using tiled, multi-resolution TIFFs. The Lambda Function wrapper included in this application assumes a .tif
extension unless you set ResolverTemplate in your .env file.
Some versions of libvips
and libjpeg
have an issue with JPEG-compressed pyramidal TIFF images that include more than 3 channels (e.g.,
alpha channels). If you find that serverless-iiif
returns an error for an image request or isn't rendering as you'd expect, try removing any additional channels beyond red, green, and blue.
Image Metadata
serverless-iiif
will probe each source image for its dimensions before any other processing takes place. Because this process can be time consuming, especially for large files, serverless-iiif
first looks for fields calls x-amz-meta-width
and x-amz-meta-height
in the source file's S3 Object Metadata (opens in a new tab) before trying to load dimensions from the image itself. If those properties are present, they will be used instead.
Creating tiled TIFFs
Using the VIPS command line
# For a 3-channel source image
vips tiffsave source_image.tif output_image.tif --tile --pyramid --compression jpeg --tile-width 256 --tile-height 256
# For a source image with an alpha channel
vips extract_band source_image.tif temp_image.v 0 --n 3 \
&& vips tiffsave temp_image.v output_image.tif --tile --pyramid --compression jpeg --tile-width 256 --tile-height 256 \
&& rm temp_image.v
Using ImageMagick
convert source_image.tif -alpha off -define tiff:tile-geometry=256x256 -compress jpeg 'ptif:output_image.tif'