0
0
Fork 0

Use blob URL for Tesseract to avoid CORS issues (#11964)

This commit is contained in:
ThibG 2019-09-27 02:16:11 +02:00 committed by Eugen Rochko
parent f31530b74d
commit 7baedcb61e
3 changed files with 17 additions and 6 deletions

View file

@ -173,7 +173,17 @@ class FocalPointModal extends ImmutablePureComponent {
langPath: `${assetHost}/ocr/lang-data`,
});
worker.recognize(media.get('url'))
let media_url = media.get('file');
if (window.URL && URL.createObjectURL) {
try {
media_url = URL.createObjectURL(media.get('file'));
} catch (error) {
console.error(error);
}
}
worker.recognize(media_url)
.progress(({ progress }) => this.setState({ progress }))
.finally(() => worker.terminate())
.then(({ text }) => this.setState({ description: removeExtraLineBreaks(text), dirty: true, detecting: false }))