sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Get operation progress information with handler function

Open tchambard opened this issue 4 years ago • 1 comments

First of all, thanks for the great job done with sharp !!! It is a very powerful tool for images manipulation...

I would like to get some information about progression (percentage or weight) of current image operation (eg: crop, resize, tiles...)

I didn't found anything about this need in all existing issues...

I imagine a handler function injection like :

var transformer = sharp()
  .resize(300)
  .on('progress', function(progress) {
    console.log('Processing: ' + progress.percent + '% done');
  });

I know libvips consider an environment variable named VIPS_PROGRESS, so I guess there is something to do ?

tchambard avatar Apr 30 '20 14:04 tchambard

By setting the VIPS_PROGRESS environment variable, which outputs percentage progress to stdout, you'll be able to assess how accurate this might be for a given operation.

Happy to accept a PR if you're able. This will require the use of AsyncProgressWorker and a minimum of N-API version 5, so would have to wait until we drop support for Node.js 10.

lovell avatar Apr 30 '20 14:04 lovell