mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 15:25:07 +01:00
Ensure id attr can be set for IIIF tile output #2612
This commit is contained in:
@@ -279,6 +279,7 @@ const Sharp = function (input, options) {
|
||||
tileSkipBlanks: -1,
|
||||
tileBackground: [255, 255, 255, 255],
|
||||
tileCentre: false,
|
||||
tileId: 'https://example.com/iiif',
|
||||
linearA: 1,
|
||||
linearB: 0,
|
||||
// Function to notify of libvips warnings
|
||||
|
||||
@@ -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'])) {
|
||||
|
||||
Reference in New Issue
Block a user