Skip to content

Tesseract - Running in Browser Console #918

Description

@DigitalGyspy

Sorry, I know this is not an issue at all, so I apologise for posting here.

I am trying to use Tesseract within the browser console. This is for a site for which is not my own so I cannot embed external scripts for security reasons, hence why I run my code in the browser console. However, it is only for personal use and for intention of reading data from a canvas image.

I embedded the JS from 'https://cdn.jsdelivr.net/npm/tesseract.js@5.0.5/dist/tesseract.min.js' and then ran the following from the examples page of Tesseract GitHub pages:

(async () => {
const worker = await createWorker('eng');
const ret = await worker.recognize('https://tesseract.projectnaptha.com/img/eng_bw.png');
console.log(ret.data.text);
await worker.terminate();
})();

Which produces the following error (also because of security issues.): 'VM11097:6 Uncaught (in promise) Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://cdn.jsdelivr.net/npm/tesseract.js@v5.0.5/dist/worker.min.js' failed to load.'

Is it possible to compile the Tesseract JS files into a single block of code? Essentially, I want to bypass anything which involves referencing an external source.

Many thanks, greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions