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 several fields in the source file's S3 Object Metadata (opens in a new tab) before trying to load dimensions from the image itself.
x-amz-width/x-amz-height(orx-amz-iiif-width/x-amz-iiif-height): the width and height of the image in pixelsx-amz-pages(orx-amz-iiif-pages): the number of resolutions in the multi-resolution (pyramidal) imagex-amz-tilewidth/x-amz-tileheight(orx-amz-iiif-tilewidth/x-amz-iiif-tileheight): the tile width and height used when generating the tiled pyramidal imagex-amz-tilesize(orx-amz-iiif-tilesize): can be used instead oftilewidthandtileheightif width and height are the same
If those properties are present, they will be used instead.
Image Metadata Script
The serverless-iiif source repository includes a script that can probe one or more image files and set the appropriate width, height, pages,
and tile size metadata.
Prerequisites
Step 1
Make sure the AWS CLI is properly configured (opens in a new tab) with credentials that
have read/write access to the S3 bucket containing the images that will be served by serverless-iiif
Step 2
Clone this repository.
Step 3
Install runtime dependencies:
npm ciStep 4
Run the script:
export sourceBucket="my-image-bucket" # corresponds to the SourceBucket deploy parameter
export resolverTemplate="%s.tif" # corresponds to the ResolverTemplate deploy parameter
npm run create-metadata image_id_1 image_id_2 image_id_3Or to process every file in the bucket, regardless of type:
export sourceBucket="my-image-bucket"
export resolverTemplate="%s"
aws s3 ls --recursive s3://my-image-bucket/ \
| awk '{ print $4 }' \
| xargs -n 50 npm run create-metadataStep 5
Verify the output:
aws s3api head-object --bucket my-image-bucket --key image_id_1.tif