Changelog entry and doc refresh for #2397

This commit is contained in:
Lovell Fuller 2020-10-08 10:05:39 +01:00
parent c213e9878d
commit 20ba0f49dd
5 changed files with 15 additions and 5 deletions

View File

@ -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.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.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.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 ### Examples

View File

@ -13,6 +13,10 @@ Requires libvips v8.10.0
[#2379](https://github.com/lovell/sharp/pull/2379) [#2379](https://github.com/lovell/sharp/pull/2379)
[@jalovatt](https://github.com/jalovatt) [@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 ### v0.26.1 - 20th September 2020
* Ensure correct pageHeight when verifying multi-page image dimensions. * Ensure correct pageHeight when verifying multi-page image dimensions.

View File

@ -203,3 +203,6 @@ GitHub: https://github.com/derom
Name: Stefan Probst Name: Stefan Probst
GitHub: https://github.com/stefanprobst GitHub: https://github.com/stefanprobst
Name: Thomas Beiganz
GitHub: https://github.com/beig

View File

@ -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 {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.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 {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} * @returns {Sharp}
* @throws {Error} Invalid parameters * @throws {Error} Invalid parameters
*/ */
@ -728,8 +729,9 @@ function tile (options) {
this.options.tileSkipBlanks = 5; this.options.tileSkipBlanks = 5;
} }
// Center image in tile // Center image in tile
if (is.defined(options.centre) || is.defined(options.center)) { const centre = is.bool(options.center) ? options.center : options.centre;
this._setBooleanOption('tileCentre', options.centre || options.center); if (is.defined(centre)) {
this._setBooleanOption('tileCentre', centre);
} }
} }
// Format // Format

View File

@ -292,7 +292,7 @@ describe('Tile', function () {
it('Invalid center parameter value fail', function () { it('Invalid center parameter value fail', function () {
assert.throws(function () { assert.throws(function () {
sharp().tile({ sharp().tile({
center: 'true' centre: 'true'
}); });
}); });
}); });