From 20ba0f49dd41352c47cb50f2650478cbe22bb9e0 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Thu, 8 Oct 2020 10:05:39 +0100 Subject: [PATCH] Changelog entry and doc refresh for #2397 --- docs/api-output.md | 3 ++- docs/changelog.md | 4 ++++ docs/humans.txt | 3 +++ lib/output.js | 8 +++++--- test/unit/tile.js | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/api-output.md b/docs/api-output.md index 083ad80d..aa3ce439 100644 --- a/docs/api-output.md +++ b/docs/api-output.md @@ -372,7 +372,8 @@ Warning: multiple sharp instances concurrently producing tile output can expose - `options.skipBlanks` **[number][9]** threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images (optional, default `-1`) - `options.container` **[string][2]** tile container, with value `fs` (filesystem) or `zip` (compressed file). (optional, default `'fs'`) - `options.layout` **[string][2]** filesystem layout, possible values are `dz`, `iiif`, `zoomify` or `google`. (optional, default `'dz'`) - - `options.centre|center` **[boolean][7]** center image in tile (optional, default `false`) + - `options.centre` **[boolean][7]** centre image in tile. (optional, default `false`) + - `options.center` **[boolean][7]** alternative spelling of centre. (optional, default `false`) ### Examples diff --git a/docs/changelog.md b/docs/changelog.md index 82647539..8b5f918a 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -13,6 +13,10 @@ Requires libvips v8.10.0 [#2379](https://github.com/lovell/sharp/pull/2379) [@jalovatt](https://github.com/jalovatt) +* Add centre/center option to tile-based output. + [#2397](https://github.com/lovell/sharp/pull/2397) + [@beig](https://github.com/beig) + ### v0.26.1 - 20th September 2020 * Ensure correct pageHeight when verifying multi-page image dimensions. diff --git a/docs/humans.txt b/docs/humans.txt index 50b7a2f0..43279801 100644 --- a/docs/humans.txt +++ b/docs/humans.txt @@ -203,3 +203,6 @@ GitHub: https://github.com/derom Name: Stefan Probst GitHub: https://github.com/stefanprobst + +Name: Thomas Beiganz +GitHub: https://github.com/beig diff --git a/lib/output.js b/lib/output.js index 8ec94873..3553ae9f 100644 --- a/lib/output.js +++ b/lib/output.js @@ -658,7 +658,8 @@ function raw () { * @param {number} [options.skipBlanks=-1] threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images * @param {string} [options.container='fs'] tile container, with value `fs` (filesystem) or `zip` (compressed file). * @param {string} [options.layout='dz'] filesystem layout, possible values are `dz`, `iiif`, `zoomify` or `google`. - * @param {boolean} [options.centre=false] center image in tile. + * @param {boolean} [options.centre=false] centre image in tile. + * @param {boolean} [options.center=false] alternative spelling of centre. * @returns {Sharp} * @throws {Error} Invalid parameters */ @@ -728,8 +729,9 @@ function tile (options) { this.options.tileSkipBlanks = 5; } // Center image in tile - if (is.defined(options.centre) || is.defined(options.center)) { - this._setBooleanOption('tileCentre', options.centre || options.center); + const centre = is.bool(options.center) ? options.center : options.centre; + if (is.defined(centre)) { + this._setBooleanOption('tileCentre', centre); } } // Format diff --git a/test/unit/tile.js b/test/unit/tile.js index 4868a0e6..7fab4e4b 100644 --- a/test/unit/tile.js +++ b/test/unit/tile.js @@ -292,7 +292,7 @@ describe('Tile', function () { it('Invalid center parameter value fail', function () { assert.throws(function () { sharp().tile({ - center: 'true' + centre: 'true' }); }); });