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

Any performance benefit of using streams? #660

Closed
rexxars opened this issue Dec 22, 2016 · 2 comments
Closed

Any performance benefit of using streams? #660

rexxars opened this issue Dec 22, 2016 · 2 comments
Labels

Comments

@rexxars
Copy link
Contributor

rexxars commented Dec 22, 2016

Hi,

I've been using the streams API (piping to sharp, piping result to a stream) for my current application, but have certain cases where using streams is a bit of a pain.

For instance, I want to check the format when the metadata event is emitted, and if the file is an SVG, I don't want to transform the image at all, but just directly pipe it to the response stream, but since the input stream is already consumed by sharp, I can't get hold of the content anymore.

The alternative would of course be to just buffer the entire input into memory, so I could reuse the Buffer instance. I'm wondering if I would lose any performance doing it this way, though. I've read a couple of issues regarding streams which leads me to believe that at least output streams are not actually.. streaming. Is the same true for input streams?

@lovell
Copy link
Owner

lovell commented Dec 22, 2016

The tl;dr is no, but please do read #179 for discussion about adding stream/pipe support to libvips.

You can get away with calling metadata() on an incomplete image Buffer as long as the complete image header is present. See #298 for building this logic into sharp itself.

@rexxars
Copy link
Contributor Author

rexxars commented Dec 26, 2016

Thanks for the reply. I'll subscribe to updates on the streaming issue and hope that it will be possible in some way in the future.

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

No branches or pull requests

2 participants