tesseract.js
Advanced tools
Comparing version 4.0.3 to 4.0.4
@@ -13,5 +13,5 @@ ## Local Installation | ||
Tesseract.recognize(image, langs, { | ||
workerPath: 'https://unpkg.com/tesseract.js@v4.0.1/dist/worker.min.js', | ||
workerPath: 'https://cdn.jsdelivr.net/npm/tesseract.js@v4.0.3/dist/worker.min.js', | ||
langPath: 'https://tessdata.projectnaptha.com/4.0.0', | ||
corePath: 'https://unpkg.com/tesseract.js-core@v4.0.1/tesseract-core.wasm.js', | ||
corePath: 'https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3', | ||
}) | ||
@@ -24,5 +24,5 @@ ``` | ||
const worker = await createWorker({ | ||
workerPath: 'https://unpkg.com/tesseract.js@v4.0.1/dist/worker.min.js', | ||
workerPath: 'https://cdn.jsdelivr.net/npm/tesseract.js@v4.0.3/dist/worker.min.js', | ||
langPath: 'https://tessdata.projectnaptha.com/4.0.0', | ||
corePath: 'https://unpkg.com/tesseract.js-core@v4.0.1/tesseract-core.wasm.js', | ||
corePath: 'https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3', | ||
}); | ||
@@ -32,3 +32,3 @@ ``` | ||
### workerPath | ||
A string specifying the location of the [worker.js](./dist/worker.min.js) file. | ||
A string specifying the location of the `worker.js` file. | ||
@@ -39,4 +39,6 @@ ### langPath | ||
### corePath | ||
A string specifying the location of the [tesseract.js-core library](https://github.com/naptha/tesseract.js-core), with default value 'https://unpkg.com/tesseract.js-core@v4.0.1/tesseract-core.wasm.js'. | ||
A string specifying the location of the [tesseract.js-core library](https://github.com/naptha/tesseract.js-core), with default value 'https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3'. | ||
Another WASM option is 'https://unpkg.com/tesseract.js-core@v4.0.1/tesseract-core.js' which is a script that loads 'https://unpkg.com/tesseract.js-core@v4.0.1/tesseract-core.wasm'. But it fails to fetch at this moment. | ||
When `corePath` is a directory rather than specific `.js` file (e.g. `https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3`), Tesseract.js loads either `tesseract-core-simd.wasm.js` or `tesseract-core.wasm.js` depending on whether the users' device supports SIMD (see [https://webassembly.org/roadmap/](https://webassembly.org/roadmap/)). Therefore, if self-hosting it is important that both these files are in the location you specify for `corePath`. Having multiple files is necessary as the SIMD-enabled version is *significantly* faster (for the LSTM model [the default]), however is not yet supported on all devices. | ||
When `corePath` is set to a specific `.js` file (e.g. `https://cdn.jsdelivr.net/npm/tesseract.js-core@v4.0.3/tesseract-core.wasm.js`), it will load that file regardless of whether the users' device supports SIMD or not. This behavior exists to preserve backwards compatibility--specifying a directory that contains both files is strongly recommended. Specifying a single file will either result in much slower performance (if `tesseract-core.wasm.js` is specified) or failure to run on certain devices (if `tesseract-core-simd.wasm.js` is specified). |
{ | ||
"name": "tesseract.js", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"description": "Pure Javascript Multilingual OCR", | ||
@@ -11,3 +11,3 @@ "main": "src/index.js", | ||
"start": "node scripts/server.js", | ||
"build": "rimraf dist && webpack --config scripts/webpack.config.prod.js && rollup -c scripts/rollup.esm.js", | ||
"build": "rimraf dist && webpack --config scripts/webpack.config.prod.js && rollup -c scripts/rollup.esm.mjs", | ||
"profile:tesseract": "webpack-bundle-analyzer dist/tesseract-stats.json", | ||
@@ -39,38 +39,38 @@ "profile:worker": "webpack-bundle-analyzer dist/worker-stats.json", | ||
"devDependencies": { | ||
"@babel/core": "^7.18.7", | ||
"@babel/preset-env": "^7.18.7", | ||
"@rollup/plugin-commonjs": "^22.0.2", | ||
"acorn": "^6.4.0", | ||
"babel-loader": "^8.2.0", | ||
"@babel/core": "^7.21.4", | ||
"@babel/eslint-parser": "^7.21.3", | ||
"@babel/preset-env": "^7.21.4", | ||
"@rollup/plugin-commonjs": "^24.1.0", | ||
"acorn": "^8.8.2", | ||
"babel-loader": "^9.1.2", | ||
"buffer": "^6.0.3", | ||
"cors": "^2.8.5", | ||
"eslint": "^7.2.0", | ||
"eslint-config-airbnb-base": "^14.2.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint": "^7.32.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-plugin-import": "^2.27.5", | ||
"expect.js": "^0.3.1", | ||
"express": "^4.17.1", | ||
"mocha": "^10.0.0", | ||
"express": "^4.18.2", | ||
"mocha": "^10.2.0", | ||
"mocha-headless-chrome": "^4.0.0", | ||
"npm-run-all": "^4.1.5", | ||
"nyc": "^15.1.0", | ||
"rimraf": "^2.7.1", | ||
"rollup": "^2.79.0", | ||
"wait-on": "^3.3.0", | ||
"webpack": "^5.74.0", | ||
"webpack-bundle-analyzer": "^4.6.0", | ||
"webpack-cli": "^4.10.0", | ||
"webpack-dev-middleware": "^5.3.3" | ||
"rimraf": "^5.0.0", | ||
"rollup": "^3.20.7", | ||
"wait-on": "^7.0.1", | ||
"webpack": "^5.79.0", | ||
"webpack-bundle-analyzer": "^4.8.0", | ||
"webpack-cli": "^5.0.1", | ||
"webpack-dev-middleware": "^6.0.2" | ||
}, | ||
"dependencies": { | ||
"babel-eslint": "^10.1.0", | ||
"bmp-js": "^0.1.0", | ||
"file-type": "^12.4.1", | ||
"idb-keyval": "^3.2.0", | ||
"is-electron": "^2.2.0", | ||
"file-type": "^12.4.2", | ||
"idb-keyval": "^6.2.0", | ||
"is-electron": "^2.2.2", | ||
"is-url": "^1.2.4", | ||
"node-fetch": "^2.6.0", | ||
"opencollective-postinstall": "^2.0.2", | ||
"node-fetch": "^2.6.9", | ||
"opencollective-postinstall": "^2.0.3", | ||
"regenerator-runtime": "^0.13.3", | ||
"resolve-url": "^0.2.1", | ||
"tesseract.js-core": "^4.0.3", | ||
"tesseract.js-core": "^4.0.4", | ||
"wasm-feature-detect": "^1.2.11", | ||
@@ -77,0 +77,0 @@ "zlibjs": "^0.3.1" |
@@ -105,3 +105,3 @@ <p align="center"> | ||
<!-- v4 --> | ||
<script src='https://unpkg.com/tesseract.js@4.0.2/dist/tesseract.min.js'></script> | ||
<script src='https://cdn.jsdelivr.net/npm/tesseract.js@4/dist/tesseract.min.js'></script> | ||
``` | ||
@@ -108,0 +108,0 @@ After including the script the `Tesseract` variable will be globally available. |
@@ -11,2 +11,3 @@ const path = require('path'); | ||
mode: 'development', | ||
devtool: 'source-map', | ||
entry, | ||
@@ -13,0 +14,0 @@ output: { |
@@ -9,18 +9,30 @@ const { simd } = require('wasm-feature-detect'); | ||
// If the user specifies a core path, we use that | ||
// Otherwise, we detect the correct core based on SIMD support | ||
let corePathImport = corePath; | ||
if (!corePathImport) { | ||
// Otherwise, default to CDN | ||
const corePathImport = corePath || `https://cdn.jsdelivr.net/npm/tesseract.js-core@v${dependencies['tesseract.js-core'].substring(1)}`; | ||
// If a user specifies a specific JavaScript file, load that file. | ||
// Otherwise, assume a directory has been provided, and load either | ||
// tesseract-core.wasm.js or tesseract-core-simd.wasm.js depending | ||
// on whether this device has SIMD support. | ||
let corePathImportFile; | ||
if (corePathImport.slice(-2) === 'js') { | ||
corePathImportFile = corePathImport; | ||
} else { | ||
const simdSupport = await simd(); | ||
if (simdSupport) { | ||
corePathImport = `https://unpkg.com/tesseract.js-core@v${dependencies['tesseract.js-core'].substring(1)}/tesseract-core-simd.wasm.js`; | ||
corePathImportFile = `${corePathImport.replace(/\/$/, '')}/tesseract-core-simd.wasm.js`; | ||
} else { | ||
corePathImport = `https://unpkg.com/tesseract.js-core@v${dependencies['tesseract.js-core'].substring(1)}/tesseract-core.wasm.js`; | ||
corePathImportFile = `${corePathImport.replace(/\/$/, '')}/tesseract-core.wasm.js`; | ||
} | ||
} | ||
global.importScripts(corePathImport); | ||
// Create a module named `global.TesseractCore` | ||
global.importScripts(corePathImportFile); | ||
if (typeof global.TesseractCoreWASM !== 'undefined' && typeof WebAssembly === 'object') { | ||
// Tesseract.js-core versions through 4.0.3 create a module named `global.TesseractCoreWASM`, | ||
// so we account for that here to preserve backwards compatibility. | ||
// This part can be removed when Tesseract.js-core v4.0.3 becomes incompatible for other reasons | ||
if (typeof global.TesseractCore === 'undefined' && typeof global.TesseractCoreWASM !== 'undefined' && typeof WebAssembly === 'object') { | ||
global.TesseractCore = global.TesseractCoreWASM; | ||
} else { | ||
} else if (typeof global.TesseractCore === 'undefined') { | ||
throw Error('Failed to load TesseractCore'); | ||
@@ -27,0 +39,0 @@ } |
@@ -309,4 +309,8 @@ /** | ||
api.FindLines(); | ||
const rotateRadiansCalc = api.GetAngle(); | ||
// The function GetAngle will be replaced with GetGradient in 4.0.4, | ||
// but for now we want to maintain compatibility. | ||
// We can switch to only using GetGradient in v5. | ||
const rotateRadiansCalc = api.GetGradient ? api.GetGradient() : api.GetAngle(); | ||
// Restore user-provided PSM setting | ||
@@ -313,0 +317,0 @@ if (psmEdit) { |
@@ -12,3 +12,3 @@ const resolveURL = require('resolve-url'); | ||
? resolveURL(`/dist/worker.dev.js?nocache=${Math.random().toString(36).slice(3)}`) | ||
: `https://unpkg.com/tesseract.js@v${version}/dist/worker.min.js`, | ||
: `https://cdn.jsdelivr.net/npm/tesseract.js@v${version}/dist/worker.min.js`, | ||
/* | ||
@@ -15,0 +15,0 @@ * If browser doesn't support WebAssembly, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12
3391
27357814
24
+ Addedidb-keyval@6.2.1(transitive)
- Removedbabel-eslint@^10.1.0
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/generator@7.26.2(transitive)
- Removed@babel/helper-string-parser@7.25.9(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@babel/parser@7.26.2(transitive)
- Removed@babel/template@7.25.9(transitive)
- Removed@babel/traverse@7.25.9(transitive)
- Removed@babel/types@7.26.0(transitive)
- Removed@eslint-community/eslint-utils@4.4.1(transitive)
- Removed@eslint-community/regexpp@4.12.1(transitive)
- Removed@eslint/config-array@0.18.0(transitive)
- Removed@eslint/core@0.7.0(transitive)
- Removed@eslint/eslintrc@3.1.0(transitive)
- Removed@eslint/js@9.14.0(transitive)
- Removed@eslint/object-schema@2.1.4(transitive)
- Removed@eslint/plugin-kit@0.2.2(transitive)
- Removed@humanfs/core@0.19.1(transitive)
- Removed@humanfs/node@0.16.6(transitive)
- Removed@humanwhocodes/module-importer@1.0.1(transitive)
- Removed@humanwhocodes/retry@0.3.10.4.1(transitive)
- Removed@jridgewell/gen-mapping@0.3.5(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/set-array@1.2.1(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@jridgewell/trace-mapping@0.3.25(transitive)
- Removed@types/estree@1.0.6(transitive)
- Removed@types/json-schema@7.0.15(transitive)
- Removedacorn@8.14.0(transitive)
- Removedacorn-jsx@5.3.2(transitive)
- Removedajv@6.12.6(transitive)
- Removedansi-styles@4.3.0(transitive)
- Removedargparse@2.0.1(transitive)
- Removedbabel-eslint@10.1.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcallsites@3.1.0(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcross-spawn@7.0.5(transitive)
- Removeddebug@4.3.7(transitive)
- Removeddeep-is@0.1.4(transitive)
- Removedescape-string-regexp@4.0.0(transitive)
- Removedeslint@9.14.0(transitive)
- Removedeslint-scope@8.2.0(transitive)
- Removedeslint-visitor-keys@1.3.03.4.34.2.0(transitive)
- Removedespree@10.3.0(transitive)
- Removedesquery@1.6.0(transitive)
- Removedesrecurse@4.3.0(transitive)
- Removedestraverse@5.3.0(transitive)
- Removedesutils@2.0.3(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfast-levenshtein@2.0.6(transitive)
- Removedfile-entry-cache@8.0.0(transitive)
- Removedfind-up@5.0.0(transitive)
- Removedflat-cache@4.0.1(transitive)
- Removedflatted@3.3.1(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedglob-parent@6.0.2(transitive)
- Removedglobals@11.12.014.0.0(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedidb-keyval@3.2.0(transitive)
- Removedignore@5.3.2(transitive)
- Removedimport-fresh@3.3.0(transitive)
- Removedimurmurhash@0.1.4(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedisexe@2.0.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjs-yaml@4.1.0(transitive)
- Removedjsesc@3.0.2(transitive)
- Removedjson-buffer@3.0.1(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stable-stringify-without-jsonify@1.0.1(transitive)
- Removedkeyv@4.5.4(transitive)
- Removedlevn@0.4.1(transitive)
- Removedlocate-path@6.0.0(transitive)
- Removedlodash.merge@4.6.2(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedms@2.1.3(transitive)
- Removednatural-compare@1.4.0(transitive)
- Removedoptionator@0.9.4(transitive)
- Removedp-limit@3.1.0(transitive)
- Removedp-locate@5.0.0(transitive)
- Removedparent-module@1.0.1(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedpath-key@3.1.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedprelude-ls@1.2.1(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedresolve-from@4.0.0(transitive)
- Removedshebang-command@2.0.0(transitive)
- Removedshebang-regex@3.0.0(transitive)
- Removedstrip-json-comments@3.1.1(transitive)
- Removedsupports-color@7.2.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtext-table@0.2.0(transitive)
- Removedtype-check@0.4.0(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedwhich@2.0.2(transitive)
- Removedword-wrap@1.2.5(transitive)
- Removedyocto-queue@0.1.0(transitive)
Updatedfile-type@^12.4.2
Updatedidb-keyval@^6.2.0
Updatedis-electron@^2.2.2
Updatednode-fetch@^2.6.9
Updatedtesseract.js-core@^4.0.4