sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Enhancement: add tiled Buffer (and Stream) output

Open lovell opened this issue 4 years ago • 5 comments

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

lovell avatar Jun 03 '20 17:06 lovell

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 avatar Aug 18 '20 10:08 Talbot3

@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.

lovell avatar Aug 18 '20 15:08 lovell

Any progress on this? Seems like a very useful feature.

nikolay-atypon avatar Sep 25 '20 19:09 nikolay-atypon

@lovell Is this ready to use?

manfwh avatar Sep 25 '21 03:09 manfwh

Commit https://github.com/lovell/sharp/commit/b46ab510da4358ff6de32b8d23bc29882b1151af adds support for tile output via Stream and Buffer. This will be in v0.31.0.

lovell avatar Jul 24 '22 10:07 lovell

v0.31.0 now available with this improvement.

lovell avatar Sep 05 '22 09:09 lovell