commonsmachinery / blockhash-js

Image perceptual hash calculation in javascript
http://blockhash.io/
MIT License
172 stars 49 forks source link

Detect image type from arrayBuffer #3

Open denisnazarov opened 10 years ago

denisnazarov commented 10 years ago

blockhash-js should be able to detect the image type from the arrayBuffer directly, without having to resort to the content type of the xhr request. See:

http://stackoverflow.com/questions/8349693/how-to-check-if-a-byte-array-is-a-valid-image http://stackoverflow.com/questions/25841460/how-to-recognise-the-arraybuffer-is-string-or-image http://stackoverflow.com/questions/4550296/how-to-identify-contents-of-a-byte-is-a-jpeg

This would allow the library to support hashing from an arrayBuffer from an instance of the FileReader class without having to supply content type.

https://developer.mozilla.org/en-US/docs/Web/API/FileReader