Add Buffer and Stream support to tile output #2238

This commit is contained in:
Lovell Fuller
2022-07-24 11:06:41 +01:00
parent 3e327a586c
commit b46ab510da
8 changed files with 161 additions and 56 deletions

View File

@@ -544,9 +544,12 @@ const data = await sharp('input.png')
## tile
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`.
### Parameters
* `options` **[Object][6]?**
@@ -562,6 +565,7 @@ Use a `.zip` or `.szi` file extension with `toFile` to write to a compressed arc
* `options.centre` **[boolean][10]** centre image in tile. (optional, default `false`)
* `options.center` **[boolean][10]** alternative spelling of centre. (optional, default `false`)
* `options.id` **[string][2]** when `layout` is `iiif`/`iiif3`, sets the `@id`/`id` attribute of `info.json` (optional, default `'https://example.com/iiif'`)
* `options.basename` **[string][2]?** the name of the directory within the zip file when container is `zip`.
### Examples
@@ -577,6 +581,19 @@ sharp('input.tiff')
});
```
```javascript
const zipFileWithTiles = await sharp(input)
.tile({ basename: "tiles" })
.toBuffer();
```
```javascript
const iiififier = sharp().tile({ layout: "iiif" });
readableStream
.pipe(iiififier)
.pipe(writeableStream);
```
* Throws **[Error][4]** Invalid parameters
Returns **Sharp**

View File

@@ -15,6 +15,9 @@ Requires libvips v8.13.0
* Use combined bounding box of alpha and non-alpha channels for `trim` operation.
[#2166](https://github.com/lovell/sharp/issues/2166)
* Add Buffer and Stream support to tile-based output.
[#2238](https://github.com/lovell/sharp/issues/2238)
* Add input `fileSuffix` and output `alias` to `format` information.
[#2642](https://github.com/lovell/sharp/issues/2642)

File diff suppressed because one or more lines are too long