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

inferImageType is excessively slow #303

Closed
hfossli-agens opened this issue Sep 8, 2021 · 2 comments
Closed

inferImageType is excessively slow #303

hfossli-agens opened this issue Sep 8, 2021 · 2 comments
Labels

Comments

@hfossli-agens
Copy link

Converting the whole buffer to a hex string to only read the first few bytes is totally unnecessary.

Current code:

 inferImageType(imageBuffer) {
    switch(imageBuffer.toString('hex').substring(0,8).toUpperCase()) {

Suggestion (not tested):

 inferImageType(imageBuffer) {
    switch(imageBuffer.slice(0, 4).toString('hex').toUpperCase()) {
@gattasrikanth
Copy link

Thanks for the report. I have added this to our backlog items.

@fisenkodv
Copy link
Contributor

@hfossli-agens, we have updated our solution, the issue has been fixed. If you still see the issue with the latest version (v6.0.0), please feel free to reopen the issue.

You can refer to the recent changes here.

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

3 participants