sharp
sharp copied to clipboard
Enhancement: add tiled Buffer (and Stream) output
Will use vips_dzsave_buffer
, forces container
property to have a value of "zip".
Requires exposing the basename
property (libvips default is "undefined").
:point_down: PROPOSED API - NOT YET AVAILABLE
const zipFileWithTiles = await sharp(input)
.tile({ basename: "tiles" })
.toBuffer();
const iiififier = sharp().tile({ layout: "iiif" });
readableStream
.pipe(iiififier)
.pipe(writeableStream);
:point_up: PROPOSED API - NOT YET AVAILABLE
Thank your tips.here is my code that run pass.
const img = require('sharp');
const fs = require('fs');
const imgStream = img().tile().toFormat('jpg').resize(320, 240);
console.log(imgStream.format)
const path = require('path');
let rStream = fs.createReadStream(path.join(__dirname, 'test.jpg').toString());
let wStream = fs.createWriteStream('./test.haha.jpg');
rStream.pipe(imgStream).pipe(wStream);
@Talbot3 This future possible enhancement is about Streaming a zip file containing multiple tile-based deep zoom (image pyramid) images with complete directory structure. The use of toFormat('jpg')
in your sample code means it will only output one image.
Any progress on this? Seems like a very useful feature.
@lovell Is this ready to use?
Commit https://github.com/lovell/sharp/commit/b46ab510da4358ff6de32b8d23bc29882b1151af adds support for tile
output via Stream and Buffer. This will be in v0.31.0.
v0.31.0 now available with this improvement.