mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add Buffer and Stream support to tile output #2238
This commit is contained in:
@@ -943,9 +943,12 @@ function raw (options) {
|
||||
|
||||
/**
|
||||
* Use tile-based deep zoom (image pyramid) output.
|
||||
*
|
||||
* Set the format and options for tile images via the `toFormat`, `jpeg`, `png` or `webp` functions.
|
||||
* Use a `.zip` or `.szi` file extension with `toFile` to write to a compressed archive file format.
|
||||
*
|
||||
* The container will be set to `zip` when the output is a Buffer or Stream, otherwise it will default to `fs`.
|
||||
*
|
||||
* @example
|
||||
* sharp('input.tiff')
|
||||
* .png()
|
||||
@@ -957,6 +960,17 @@ function raw (options) {
|
||||
* // output_files contains 512x512 tiles grouped by zoom level
|
||||
* });
|
||||
*
|
||||
* @example
|
||||
* const zipFileWithTiles = await sharp(input)
|
||||
* .tile({ basename: "tiles" })
|
||||
* .toBuffer();
|
||||
*
|
||||
* @example
|
||||
* const iiififier = sharp().tile({ layout: "iiif" });
|
||||
* readableStream
|
||||
* .pipe(iiififier)
|
||||
* .pipe(writeableStream);
|
||||
*
|
||||
* @param {Object} [options]
|
||||
* @param {number} [options.size=256] tile size in pixels, a value between 1 and 8192.
|
||||
* @param {number} [options.overlap=0] tile overlap in pixels, a value between 0 and 8192.
|
||||
@@ -969,6 +983,7 @@ function raw (options) {
|
||||
* @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`/`iiif3`, sets the `@id`/`id` attribute of `info.json`
|
||||
* @param {string} [options.basename] the name of the directory within the zip file when container is `zip`.
|
||||
* @returns {Sharp}
|
||||
* @throws {Error} Invalid parameters
|
||||
*/
|
||||
@@ -1050,6 +1065,14 @@ function tile (options) {
|
||||
throw is.invalidParameterError('id', 'string', options.id);
|
||||
}
|
||||
}
|
||||
// Basename for zip container
|
||||
if (is.defined(options.basename)) {
|
||||
if (is.string(options.basename)) {
|
||||
this.options.tileBasename = options.basename;
|
||||
} else {
|
||||
throw is.invalidParameterError('basename', 'string', options.basename);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Format
|
||||
if (is.inArray(this.options.formatOut, ['jpeg', 'png', 'webp'])) {
|
||||
|
||||
Reference in New Issue
Block a user