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

SharpCache option in express-processimage #17

Open
ramasamymohan opened this issue Aug 10, 2016 · 3 comments
Open

SharpCache option in express-processimage #17

ramasamymohan opened this issue Aug 10, 2016 · 3 comments

Comments

@ramasamymohan
Copy link

I was trying to use sharpCache option to cache images,

app.use(processImage({ root: 'public', sharpCache: { items: 200,files: 30 } }));

If sharpCache option is not given I think it should take default sharp cache option.
Is sharpCache option working?

Everytime, when an image is processed through url query string it uses more cpu. If it can cache it in file system, I believe it can process image faster. Any idea?

Thank you.

@papandreou
Copy link
Owner

Hi!

As you've found, the sharpCache option maps directly to http://sharp.dimens.io/en/stable/api/#sharpcacheoptions -- but unfortunately libvips' operation cache only applies to files loaded from disc, which doesn't happen with express-processimage, because it uses the stream-based input. In cases where express-processimage sits directly on top of eg. the static middleware, that's probably a bit silly, especially if you'd like for the caching to work :)

We could consider introducing a mode where express-processimage takes control of loading the file from disc and hands the file name to the image libs, thus enabling the use of the sharp cache. Would that fix your use case?

@ramasamymohan
Copy link
Author

I appreciate your quick reply.
It would be great if a mode can enable sharp cache and if express-processimage could take control to load the image from disc.

Thank you.

@papandreou
Copy link
Owner

Okay, thanks. I might look into implementing that when I get around to integrate https://github.com/papandreou/impro -- I can't make any guarantees about when that will happen, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants