Skip to content

Provide pre-pipeline function to modify options based on input image metadata #236

@lovell

Description

@lovell

This could seriously increase the power of Stream-based image processing.

Here's an example of how halving an image's dimensions could work:

// PROPOSED API NOT YET AVAILABLE
var halver = sharp().before(function(metadata) {
  this.resize(metadata.width / 2, metadata.height / 2);
});
readableStream.pipe(halver).pipe(writableStream);
// PROPOSED API NOT YET AVAILABLE

The existing metadata logic can also be improved to require only the first few hundred bytes of a Stream.

In addition, adding a "playbook" of example uses for this feature to the docs would be great too. There's a variable/percentage extract/crop under discussion at #205 that this should allow for.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions