Ensure id attr can be set for IIIF tile output #2612

This commit is contained in:
Lovell Fuller
2021-03-12 19:42:23 +00:00
parent 5a9cc835b3
commit 00aece0538
6 changed files with 40 additions and 2 deletions

View File

@@ -727,6 +727,7 @@ function raw () {
* @param {string} [options.layout='dz'] filesystem layout, possible values are `dz`, `iiif`, `zoomify` or `google`.
* @param {boolean} [options.centre=false] centre image in tile.
* @param {boolean} [options.center=false] alternative spelling of centre.
* @param {string} [options.id='https://example.com/iiif'] when `layout` is `iiif`, sets the `@id` attribute of `info.json`
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
@@ -800,6 +801,14 @@ function tile (options) {
if (is.defined(centre)) {
this._setBooleanOption('tileCentre', centre);
}
// @id attribute for IIIF layout
if (is.defined(options.id)) {
if (is.string(options.id)) {
this.options.tileId = options.id;
} else {
throw is.invalidParameterError('id', 'string', options.id);
}
}
}
// Format
if (is.inArray(this.options.formatOut, ['jpeg', 'png', 'webp'])) {