The create-metadata script can probe one or more image files and set the appropriate width, height, pages, and tile size metadata. It can be invoked three different ways:
- As a standalone script
- As a Lambda function
- As an S3 Batch Operation
Standalone Script Invocation
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 the serverless-iiif repository (opens in a new tab).
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.tifLambbda Function Invocation
Prerequisites
- A
serverless-iiifapplication stack deployed withCreateMetadataFunctionset totrue
Step 1
Get the value of the MetadataFunctionARN output from the deployed stack.
Step 2
Determine the ID of the image (as it will look in the ID part of the IIIF URL).
Step 3
Invoke the Lambda Function (opens in a new tab) with the payload { imageId: "ID_OF_IMAGE" }
S3 Batch Operation Invocation
Prerequisites
- A
serverless-iiifapplication stack deployed withCreateMetadataFunctionset totrue
Step 1
Get the value of the MetadataFunctionARN output from the deployed stack.
Step 2
Create an S3 Batch Operation (opens in a new tab) specifying the MetadataFunctionARN as the operation. The manifest must only include objects from the image source bucket, as that is the only bucket the Lambda Function has access to.