tesseract.js
tesseract.js copied to clipboard
Add support for ImageData and fix a hang in buffer handling
Addresses two concerns:
- The
setImage()function started to hang for a long period of time (several seconds for a 1080p image, for example) trying to handle the buffer. I don't quite know why the code was written as it was originally, but changing that one line has stopped it hanging. - Adds support for the
ImageDataobtained from canvases. This improves performance by allowing you to bypasstoBlob()/toDataURL()(which would convert to a PNG first), if that's the data format you already have.
Thanks for this contribution. I agree that it makes sense to pass ImageData directly rather than converting to .png.
This had to be reverted as it does not run on Node. 100% my fault for not checking first, however in the future please run the automated tests before making a PR (npm run test).