Add centre/center option to tile-based output (#2397)

This commit is contained in:
beig
2020-10-08 10:51:54 +02:00
committed by GitHub
parent 9704ca4c18
commit c213e9878d
7 changed files with 58 additions and 0 deletions

View File

@@ -238,6 +238,7 @@ const Sharp = function (input, options) {
tileAngle: 0,
tileSkipBlanks: -1,
tileBackground: [255, 255, 255, 255],
tileCentre: false,
linearA: 1,
linearB: 0,
// Function to notify of libvips warnings

View File

@@ -658,6 +658,7 @@ 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.
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
@@ -726,6 +727,10 @@ function tile (options) {
} else if (is.defined(options.layout) && options.layout === 'google') {
this.options.tileSkipBlanks = 5;
}
// Center image in tile
if (is.defined(options.centre) || is.defined(options.center)) {
this._setBooleanOption('tileCentre', options.centre || options.center);
}
}
// Format
if (is.inArray(this.options.formatOut, ['jpeg', 'png', 'webp'])) {