mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 15:25:07 +01:00
Add skipBlanks support for tile layout (#1687)
This commit is contained in:
committed by
Lovell Fuller
parent
b737d4601e
commit
6c02949fc1
@@ -539,6 +539,7 @@ function toFormat (format, options) {
|
||||
* @param {Number} [tile.overlap=0] tile overlap in pixels, a value between 0 and 8192.
|
||||
* @param {Number} [tile.angle=0] tile angle of rotation, must be a multiple of 90.
|
||||
* @param {String} [tile.depth] how deep to make the pyramid, possible values are `onepixel`, `onetile` or `one`, default based on layout.
|
||||
* @param {Number} [tile.skipBlanks=-1] threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images
|
||||
* @param {String} [tile.container='fs'] tile container, with value `fs` (filesystem) or `zip` (compressed file).
|
||||
* @param {String} [tile.layout='dz'] filesystem layout, possible values are `dz`, `zoomify` or `google`.
|
||||
* @returns {Sharp}
|
||||
@@ -599,6 +600,21 @@ function tile (tile) {
|
||||
throw new Error("Invalid tile depth '" + tile.depth + "', should be one of 'onepixel', 'onetile' or 'one'");
|
||||
}
|
||||
}
|
||||
|
||||
// Threshold of skipping blanks,
|
||||
if (is.defined(tile.skipBlanks)) {
|
||||
if (is.integer(tile.skipBlanks) && is.inRange(tile.skipBlanks, -1, 65535)) {
|
||||
this.options.skipBlanks = tile.skipBlanks;
|
||||
} else {
|
||||
throw new Error('Invalid skipBlank threshold (-1 to 255/65535) ' + tile.skipBlanks);
|
||||
}
|
||||
} else {
|
||||
if (is.defined(tile.layout) && tile.layout === 'google') {
|
||||
this.options.skipBlanks = 5;
|
||||
} else {
|
||||
this.options.skipBlanks = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Format
|
||||
if (is.inArray(this.options.formatOut, ['jpeg', 'png', 'webp'])) {
|
||||
|
||||
Reference in New Issue
Block a user