{"id":13553581,"url":"https://github.com/danschultzer/receipt-scanner","last_synced_at":"2025-04-07T12:03:34.907Z","repository":{"id":57349139,"uuid":"64558575","full_name":"danschultzer/receipt-scanner","owner":"danschultzer","description":"Receipt scanner extracts information from your PDF or image receipts - built in NodeJS","archived":false,"fork":false,"pushed_at":"2018-11-18T17:57:32.000Z","size":3714,"stargazers_count":299,"open_issues_count":8,"forks_count":56,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-31T11:04:28.616Z","etag":null,"topics":["extract-data","extract-information","ocr","optical-character-recognition","receipt-scanner","receipts"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danschultzer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-30T18:29:06.000Z","updated_at":"2025-02-03T08:32:30.000Z","dependencies_parsed_at":"2022-08-29T14:41:05.653Z","dependency_job_id":null,"html_url":"https://github.com/danschultzer/receipt-scanner","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danschultzer%2Freceipt-scanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danschultzer%2Freceipt-scanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danschultzer%2Freceipt-scanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danschultzer%2Freceipt-scanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danschultzer","download_url":"https://codeload.github.com/danschultzer/receipt-scanner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648874,"owners_count":20972944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extract-data","extract-information","ocr","optical-character-recognition","receipt-scanner","receipts"],"created_at":"2024-08-01T12:02:28.715Z","updated_at":"2025-04-07T12:03:34.859Z","avatar_url":"https://github.com/danschultzer.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","others","📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"# receipt-scanner\n\nReceipt scanner extracts information from your PDF or image receipts.\n\n[![Travis](https://img.shields.io/travis/danschultzer/receipt-scanner/master.svg)](https://travis-ci.org/danschultzer/receipt-scanner/)\n[![NPM version](https://img.shields.io/npm/v/receipt-scanner.svg)](https://www.npmjs.com/package/receipt-scanner)\n[![Codecov](https://img.shields.io/codecov/c/github/danschultzer/receipt-scanner/master.svg)](https://codecov.io/gh/danschultzer/receipt-scanner)\n[![David](https://img.shields.io/david/danschultzer/receipt-scanner/master.svg)](https://david-dm.org/danschultzer/receipt-scanner)\n\n## Example\n\n```\nimport scanner from 'receipt-scanner'\n\nscanner(streamOrFilePath)\n  .parse(function (err, results) {\n    if (err) return console.error(err)\n    else console.log(results)\n  })\n```\n\n### CLI\n\n```\nreceipt-scanner path/to/image.png\n```\n\n### Results\n\n```\n{\n    \"path/to/image.png\": {\n        \"amount\": \"1,390.00\",\n        \"date\": \"2016-06-19\"\n    }\n}\n```\n\n## Getting started\n\n`$ brew install opencv3 poppler tesseract --with-all-languages`\n\n`$ brew link --force opencv3`\n\n`$ npm install git+https://git@github.com/danschultzer/receipt-scanner.git -g`\n\nNow run:\n\n`receipt-scanner path/to/image.png`\n\n### Command Line Interface\n\n```\n$ receipt-scanner --help\n\nUsage: receipt-scanner [options] \u003cpath...\u003e\n\nOptions:\n\n  -h, --help             output usage information\n  -f, --format \u003cformat\u003e  format to return, json (default) or text\n  -p, --progress         add a progress bar\n  -s, --summary          show summary details\n  -v, --verbose          show verbose information\n```\n\n## Optional dependencies\n\nThese dependencies are only necessary if you're going to use `imagemagick` or `graphicsmagick` image preprocessor.\n\n| Preprocessor   | Install command                        |\n| -------------- | -------------------------------------- |\n| Graphicsmagick | `$ brew install graphicsmagick`        |\n| Imagemagick    | `$ brew install imagemagick`           |\n\n## API\n\n### Custom image preprocessor\n\nYou can use, and chain, specific image preprocessors by using the `imagePreprocessor` method like so:\n\n```\nvar gm = require('gm')\n\nfunction customPreprocessor (fileOrStream, outfile, cb) {\n  gm(fileOrStream)\n   .resize(400, 200)\n   .in('-level', '25%,75%')\n   .write(outfile, function (error) {\n     cb(error, outfile)\n   })\n}\n\nimport scanner from 'receipt-scanner'\n\nscanner(streamOrFilePath)\n  .imagePreprocessor(customPreprocessor)\n  .parse(function (err, results) {\n    if (err) return console.error(err)\n    else console.log(results)\n  })\n```\n\nThe default preprocessor used is [`opencv`](lib/image_processor/preprocessor/opencv.js). It's also possible to add configuration settings by pushing an array to `imagePreprocessor` like so:\n\n```\nscanner(stream_or_file_path)\n  .imagePreprocessor(['opencv', { verbose: true }])\n```\n\n### Custom text parser\n\nYou can add a custom text parser by using the `textParser` method like so:\n\n```\nfunction customTextParser (text) {\n  var regexp = new RegExp('Description: (.*)', 'ig')\n  var output = []\n  while (var matches = regexp.exec(text)) {\n    output.push(matches[1])\n  }\n  return { matches: output, match: output[0] }\n}\n\nimport scanner from 'receipt-scanner'\n\nscanner(streamOrFilePath)\n  .textParser(customTextParser)\n  .parse(function (err, results) {\n    if (err) return console.error(err)\n    else console.log(results)\n  })\n```\n\nThe value will be added to the response object for the `customTextParser` key.\n\n### Customizing amount or date parser\n\nYou can customize either parser by setting config like so:\n\n```\nimport scanner from 'receipt-scanner'\n\nscanner(streamOrFilePath)\n  .textParser(['date', { parser: 'first' }])\n  .parse(function (err, results) {\n    if (err) return console.error(err)\n    else console.log(results)\n  })\n```\n\nDate parser will by default find the [`earliest`](lib/text_parser/date/earliest.js) date, but as shown in the example you can also find the [`first`](lib/text_parser/date/first.js). The amount parser will find the total first, and if nothing is found, then find the biggest amount.\n\n#### Date parser config options\n`parser`: What parser to run, `earliest` or `first`\n\n#### Amount parser config options\n`parsers`: What parsers to run in order. Default is `['total', 'largest']`.\n\n### Ticker\n\nA ticker callback can be added with the `ticker` method.\n\n```\nimport scanner from 'receipt-scanner'\n\nscanner(streamOrFilePath)\n  .ticker(function (percent) {\n    // Update ticker with current percent amount\n  })\n  .parse(function (err, results) {\n    if (err) return console.error(err)\n    else console.log(results)\n  })\n```\n\n### Parse text\n\nIf you've already extracted the text, and just want to parse it for the relevant information you can use `parseText`.\n\n```\nimport scanner from 'receipt-scanner'\n\nvar results = scanner().parseText(text)\n```\n\nIt'll return the same results as when you use `parse(callback)`.\n\n## How is text parsed?\n\nReceipt scanner takes an ambiguous approach to date and amounts. Amounts formatting is guessed from the number of amounts found with comma or with dots for decimal separation.\n\n## What's the binaries for?\n\n`poppler`: For pdftotext module and pdfimages binary (PDF processing)\n\n`imagemagick`: For gm module (image preprocessing)\n\n`graphicsmagick`: For gm module (image preprocessing)\n\n`opencv3`: For node-opencv (image preprocessing)\n\n`vips`: For sharp module (image preprocessing)\n\n`tesseract --all-languages`: For node-tesseract module (OCR)\n\n## Tests\n\n`$ npm test`\n\nYou can use `npm test watch` to keep tests running, and `npm run cover` for coverage.\n\n## Benchmark\n\nRun `npm run benchmark` to get success rate using the [receipt-scanner-testdata](https://github.com/danschultzer/receipt-scanner-testdata) repository.\n\nTo generate random data set to benchmark run `npm run generate-benchmark-sample`.\n\n## LICENSE\n\n(The MIT License)\n\nCopyright (c) 2016 Dan Schultzer, Benjamin Schultzer \u0026 the Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanschultzer%2Freceipt-scanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanschultzer%2Freceipt-scanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanschultzer%2Freceipt-scanner/lists"}