Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: emit post-processing 'info' event #367

Closed
salzhrani opened this issue Feb 25, 2016 · 5 comments
Closed

Feature request: emit post-processing 'info' event #367

salzhrani opened this issue Feb 25, 2016 · 5 comments
Milestone

Comments

@salzhrani
Copy link
Contributor

I am using sharp's raw input and output to do some color manipulation on images in addition to resize and crop.

var input = sharp().raw().resize(600).max().withoutEnlargement();
var process = new ColorSaturationStream();
var output = sharp(null, {raw: {
    width: newWidth,
    height: newHeight,
    channels: newChannels
}}).toFormat('jpg');

someImageStream.pipe(input).pipe(process).pipe(output).pipe(response);

the challenge is that output must have the correct newWidth and newHeight or it will throw an error like:
libc++abi.dylib: terminating with uncaught exception of type vips::VError
while knowing the original image size I can calculate what newWidth and newHeight can be, but since there is a possibility of using different rounding methods than sharp I might get the wrong values.

I currently use Math.round as sharp does but is it always going to be the case ?

One way that might help with this is to add a utility function that exposes sharp internal calculations so we can have the same values.

@lovell
Copy link
Owner

lovell commented Feb 25, 2016

Hello, we could add a feature where an instance of sharp will emit an info event with the same details as the info parameter provided to the toBuffer callback. Do you think this might provide what you need?

Given the async nature of this, you would probably need to cork the output Stream of your example until this event was emitted by the input Stream.

As an aside, we also need to check why you're seeing "terminating with uncaught exception of type vips::VError" as that should have been caught and emitted as an error event.

@salzhrani
Copy link
Contributor Author

this error message is on mac os, in linux I got more details which point to this line which is becuase of the difference in size

@salzhrani
Copy link
Contributor Author

an info event is useful, preferably if emitted early or even before pushing to the stream.

@lovell lovell changed the title getting the actual size after resize operation Feature request: emit post-processing 'info' event Feb 26, 2016
@lovell lovell added this to the v0.14.0 milestone Feb 26, 2016
@lovell
Copy link
Owner

lovell commented Mar 1, 2016

Commit 86815bc on the needle branch adds the info event for Stream-based output.

@lovell
Copy link
Owner

lovell commented Apr 2, 2016

v0.14.0 now available via npm, thanks for the original suggestion!

@lovell lovell closed this as completed Apr 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants