honza / node-thumbnail

Thumbnail worker queue for node.js
http://honza.ca/node-thumbnail/
Other
103 stars 23 forks source link

Add callback call in the resizer function. #38

Open sosfos opened 5 years ago

sosfos commented 5 years ago

Thank the team first as this library is useful in one of my project.

But when using it, I encountered one problem, when using in expressjs, which is when the user upload a fake picture (like after changing the ext of another non-pic file) and the server try to make a thumbnail of it, there will be an exception (unkown MIME type) in the jimp which will cause the resizer function to throw out the exception. But in expressjs, I cannot catch the exception which will cause the process terminate.

I am not sure whether I could find a better solution in expressjs side, but for now I just folk this project and add the callback in resizer function so that I can process the exception in the expressjs.

It will be appreciated if someone can provide a better solution without changing this lib!

honza commented 5 years ago

Also, the reason why Travis is failing is because of formatting. You can run npm run prettier to fix it.

honza commented 5 years ago

I just pushed some fixes that should take care of this. Would you mind testing your code with latest master?

sosfos commented 5 years ago

hi honza, I just checked your fix, it works in my project. It will not make the app crash after trying to creating thumbnail for a fake image, but the error was just hidden underground as you are calling the internal callback but not the customized callback.

Anyway, it's good enough for my project so far. Thanks for your fix.

By the way, the CI shows there are conflicts and I just try to fixed, not sure how to restart the ci so please help to check.