Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tesseract.js

Package Overview
Dependencies
Maintainers
3
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tesseract.js - npm Package Compare versions

Comparing version 2.0.0-alpha.8 to 2.0.0-alpha.9

.nyc_output/062c5190-b68c-4da1-ae7c-5e5c0d9f8ca5.json

15

docs/examples.md

@@ -9,2 +9,3 @@ # Tesseract.js Examples

- With Vue (similar with React/Angular): https://github.com/jeromewu/tesseract-vue-app
- Chrome Extension: https://github.com/jeromewu/tesseract.js-chrome-extension

@@ -20,3 +21,3 @@ ### basic

worker
.recognize('http://jeroen.github.io/images/testocr.png')
.recognize('https://tesseract.projectnaptha.com/img/eng_bw.png')
.then((result) => {

@@ -36,3 +37,3 @@ console.log(result);

worker
.recognize('http://jeroen.github.io/images/testocr.png')
.recognize('https://tesseract.projectnaptha.com/img/eng_bw.png')
.progress((p) => {

@@ -56,3 +57,3 @@ console.log('progress', p);

.recognize(
'http://jeroen.github.io/images/testocr.png',
'https://tesseract.projectnaptha.com/img/eng_bw.png',
'eng+chi_tra'

@@ -80,3 +81,3 @@ )

.recognize(
'http://jeroen.github.io/images/testocr.png',
'https://tesseract.projectnaptha.com/img/eng_bw.png',
'eng',

@@ -108,3 +109,3 @@ {

.recognize(
'http://jeroen.github.io/images/testocr.png',
'https://tesseract.projectnaptha.com/img/eng_bw.png',
'eng',

@@ -135,3 +136,3 @@ {

.recognize(
'http://jeroen.github.io/images/testocr.png',
'https://tesseract.projectnaptha.com/img/eng_bw.png',
'eng',

@@ -160,3 +161,3 @@ {

.recognize(
'http://jeroen.github.io/images/testocr.png',
'https://tesseract.projectnaptha.com/img/eng_bw.png',
'eng',

@@ -163,0 +164,0 @@ {

@@ -13,3 +13,3 @@ ## Local Installation

const worker = Tesseract.TesseractWorker({
workerPath: 'https://unpkg.com/tesseract.js@v2.0.0-alpha.7/dist/worker.min.js',
workerPath: 'https://unpkg.com/tesseract.js@v2.0.0-alpha.8/dist/worker.min.js',
langPath: 'https://tessdata.projectnaptha.com/4.0.0',

@@ -16,0 +16,0 @@ corePath: 'https://unpkg.com/tesseract.js-core@v2.0.0-beta.10/tesseract-core.wasm.js',

{
"name": "tesseract.js",
"version": "2.0.0-alpha.8",
"version": "2.0.0-alpha.9",
"description": "Pure Javascript Multilingual OCR",

@@ -8,3 +8,3 @@ "main": "src/index.js",

"start": "node scripts/server.js",
"build": "webpack --config scripts/webpack.config.prod.js",
"build": "rimraf dist && webpack --config scripts/webpack.config.prod.js",
"prepublishOnly": "npm run build",

@@ -45,2 +45,3 @@ "wait": "wait-on http://localhost:3000/package.json",

"nyc": "^13.1.0",
"rimraf": "^2.6.3",
"wait-on": "^3.2.0",

@@ -58,3 +59,3 @@ "webpack": "^4.26.0",

"tesseract.js-core": "^2.0.0-beta.10",
"tesseract.js-utils": "^1.0.0-beta.6"
"tesseract.js-utils": "^1.0.0-beta.8"
},

@@ -61,0 +62,0 @@ "repository": {

@@ -42,3 +42,3 @@ # [Tesseract.js](http://tesseract.projectnaptha.com/)

```html
<script src='https://unpkg.com/tesseract.js@v2.0.0-alpha.7/dist/tesseract.min.js'></script>
<script src='https://unpkg.com/tesseract.js@v2.0.0-alpha.8/dist/tesseract.min.js'></script>
```

@@ -45,0 +45,0 @@

@@ -70,8 +70,8 @@ /**

* @param {Buffer, string} image - image to be recognized
* @param {string} [lang=eng] - language to recognize
* @param {string, array} [langs=eng] - languages to recognize
* @param {object} params - tesseract parameters
*
*/
recognize(image, lang = 'eng', params = {}) {
return this._sendJob('recognize', image, lang, params);
recognize(image, langs = 'eng', params = {}) {
return this._sendJob('recognize', image, langs, params);
}

@@ -156,3 +156,3 @@

*/
_sendJob(type, image, lang, params) {
_sendJob(type, image, langs, params) {
return this._delay((job) => {

@@ -163,3 +163,3 @@ job.send(

image,
lang,
langs,
params,

@@ -166,0 +166,0 @@ options: this.options,

@@ -55,2 +55,8 @@ /**

const getLangsStr = langs => (
typeof langs === 'string'
? langs
: langs.map(lang => (typeof lang === 'string' ? lang : lang.data)).join('+')
);
/**

@@ -62,6 +68,6 @@ * handleParams

* @access private
* @param {string} lang - lang string for Init()
* @param {string} langs - lang string for Init()
* @param {object} customParams - an object of params
*/
const handleParams = (lang, customParams) => {
const handleParams = (langs, customParams) => {
const {

@@ -74,3 +80,3 @@ tessedit_ocr_engine_mode,

};
api.Init(null, lang, tessedit_ocr_engine_mode);
api.Init(null, getLangsStr(langs), tessedit_ocr_engine_mode);
Object.keys(params).forEach((key) => {

@@ -164,3 +170,3 @@ api.SetVariable(key, params[key]);

* @param {object} req - job payload
* @param {string} req.lang - languages to load, ex: eng, eng+chi_tra
* @param {string} req.langs - languages to load, ex: eng, eng+chi_tra
* @param {object} req.options - other options for loadLang function

@@ -170,5 +176,5 @@ * @param {object} res - job instance

*/
const loadLanguage = ({ lang, options }, res) => {
const loadLanguage = ({ langs, options }, res) => {
res.progress({ status: 'loading language traineddata', progress: 0 });
return loadLang({ lang, TessModule, ...options }).then((...args) => {
return loadLang({ langs, TessModule, ...options }).then((...args) => {
res.progress({ status: 'loaded language traineddata', progress: 1 });

@@ -187,3 +193,3 @@ return args;

* @param {array} req.image - binary image in array format
* @param {string} req.lang - languages to load, ex: eng, eng+chi_tra
* @param {string} req.langs - languages to load, ex: eng, eng+chi_tra
* @param {object} req.options - other options for loadLang function

@@ -194,7 +200,7 @@ * @param {object} req.params - parameters for tesseract

const handleRecognize = ({
image, lang, options, params,
image, langs, options, params,
}, res) => (
handleInit(options, res)
.then(() => (
loadLanguage({ lang, options }, res)
loadLanguage({ langs, options }, res)
.catch((e) => {

@@ -216,3 +222,3 @@ if (e instanceof DOMException) {

progressUpdate(0);
handleParams(lang, params);
handleParams(langs, params);
progressUpdate(0.5);

@@ -239,3 +245,3 @@ const ptr = setImage(image);

* @param {array} req.image - binary image in array format
* @param {string} req.lang - languages to load, ex: eng, eng+chi_tra
* @param {string} req.langs - languages to load, ex: eng, eng+chi_tra
* @param {object} req.options - other options for loadLang function

@@ -245,9 +251,9 @@ * @param {object} res - job instance

const handleDetect = ({
image, lang, options,
image, langs, options,
}, res) => (
handleInit(options, res)
.then(() => (
loadLanguage({ lang, options }, res)
loadLanguage({ langs, options }, res)
.then(() => {
api.Init(null, lang);
api.Init(null, getLangsStr(langs));
api.SetPageSegMode(TessModule.PSM_OSD_ONLY);

@@ -254,0 +260,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc