zxing


Namezxing JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://github.com/dlenski/python-zxing
SummaryWrapper for decoding/reading barcodes with ZXing (Zebra Crossing) library
upload_time2024-04-06 20:36:43
maintainerNone
docs_urlNone
authorDaniel Lenski
requires_python>=3
licenseLGPL v3 or later
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # python-zxing

[![PyPI](https://img.shields.io/pypi/v/zxing.svg)](https://pypi.python.org/pypi/zxing)
[![Build Status](https://github.com/dlenski/python-zxing/workflows/test_and_release/badge.svg)](https://github.com/dlenski/python-zxing/actions/workflows/test_and_release.yml)
[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)

This is a wrapper for the [ZXing barcode library](https://github.com/zxing/zxing).
It will allow you to read and decode barcode images from Python.

It was originally a "slightly less quick-and-dirty" fork of [oostendo/python-zxing](https://github.com/oostendo/python-zxing), but has since
evolved considerably beyond that ancestral package.

## Dependencies and installation

Use the Python 3 version of pip (usually invoked via `pip3`) to install: `pip3 install zxing`

* You'll neeed to have a recent `java` binary somewhere in your path. (Tested with OpenJDK v7, v8, v11.)
* pip will automatically download the relevant [JAR](https://en.wikipedia.org/wiki/JAR_(file_format)) files for the Java ZXing libraries (currently v3.5.3)

## Usage

The `BarCodeReader` class is used to decode images:

```python
>>> import zxing
>>> reader = zxing.BarCodeReader()
>>> print(reader.zxing_version, reader.zxing_version_info)
3.5.1 (3, 5, 1)
>>> barcode = reader.decode("test/barcodes/QR_CODE-easy.png")
>>> print(barcode)
BarCode(raw='This should be QR_CODE', parsed='This should be QR_CODE', path='test/barcodes/QR_CODE-easy.png', format='QR_CODE', type='TEXT', points=[(15.0, 87.0), (15.0, 15.0), (87.0, 15.0), (75.0, 75.0)])
```

The attributes of the decoded `BarCode` object are `raw`, `parsed`, `path`, `format`, `type`, `points`, and `raw_bits`.
The list of formats which ZXing can decode is [here](https://zxing.github.io/zxing/apidocs/com/google/zxing/BarcodeFormat.html).

The `decode()` method accepts an image path or [PIL Image object](https://pillow.readthedocs.io/en/stable/reference/Image.html) (or list thereof)
and takes optional parameters `try_harder` (boolean), `possible_formats` (list of formats to consider), and `pure_barcode` (boolean).
If no barcode is found, it returns a `False`-y `BarCode` object with all fields except `path` set to `None`.
If it encounters any other recognizable error from the Java ZXing library, it raises `BarCodeReaderException`.

## Command-line interface

The command-line interface can decode images into barcodes and output in either a human-readable or CSV format:

```
usage: zxing [-h] [-c] [--try-harder] [--pure-barcode] [-V] image [image ...]
```

Human-readable:

```sh
$ zxing /tmp/barcode.png
/tmp/barcode.png
================
  Decoded TEXT barcode in QR_CODE format.
  Raw text:    'Testing 123'
  Parsed text: 'Testing 123'
```

CSV output (can be opened by LibreOffice or Excel):

```sh
$ zxing /tmp/barcode1.png /tmp/barcode2.png /tmp/barcode3.png
Filename,Format,Type,Raw,Parsed
/tmp/barcode1.png,CODE_128,TEXT,Testing 123,Testing 123
/tmp/barcode2.png,QR_CODE,URI,http://zxing.org,http://zxing.org
/tmp/barcode3.png,QR_CODE,TEXT,"This text, ""Has stuff in it!"" Wow⏎Yes it does!","This text, ""Has stuff in it!"" Wow⏎Yes it does!"
```

## License

LGPLv3

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dlenski/python-zxing",
    "name": "zxing",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": null,
    "keywords": null,
    "author": "Daniel Lenski",
    "author_email": "dlenski@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a7/ac/2a004e63cd205900191a189028762c2e9b39e2c95f8e0f6fa50626612ac3/zxing-1.0.3.tar.gz",
    "platform": null,
    "description": "# python-zxing\n\n[![PyPI](https://img.shields.io/pypi/v/zxing.svg)](https://pypi.python.org/pypi/zxing)\n[![Build Status](https://github.com/dlenski/python-zxing/workflows/test_and_release/badge.svg)](https://github.com/dlenski/python-zxing/actions/workflows/test_and_release.yml)\n[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)\n\nThis is a wrapper for the [ZXing barcode library](https://github.com/zxing/zxing).\nIt will allow you to read and decode barcode images from Python.\n\nIt was originally a \"slightly less quick-and-dirty\" fork of [oostendo/python-zxing](https://github.com/oostendo/python-zxing), but has since\nevolved considerably beyond that ancestral package.\n\n## Dependencies and installation\n\nUse the Python 3 version of pip (usually invoked via `pip3`) to install: `pip3 install zxing`\n\n* You'll neeed to have a recent `java` binary somewhere in your path. (Tested with OpenJDK v7, v8, v11.)\n* pip will automatically download the relevant [JAR](https://en.wikipedia.org/wiki/JAR_(file_format)) files for the Java ZXing libraries (currently v3.5.3)\n\n## Usage\n\nThe `BarCodeReader` class is used to decode images:\n\n```python\n>>> import zxing\n>>> reader = zxing.BarCodeReader()\n>>> print(reader.zxing_version, reader.zxing_version_info)\n3.5.1 (3, 5, 1)\n>>> barcode = reader.decode(\"test/barcodes/QR_CODE-easy.png\")\n>>> print(barcode)\nBarCode(raw='This should be QR_CODE', parsed='This should be QR_CODE', path='test/barcodes/QR_CODE-easy.png', format='QR_CODE', type='TEXT', points=[(15.0, 87.0), (15.0, 15.0), (87.0, 15.0), (75.0, 75.0)])\n```\n\nThe attributes of the decoded `BarCode` object are `raw`, `parsed`, `path`, `format`, `type`, `points`, and `raw_bits`.\nThe list of formats which ZXing can decode is [here](https://zxing.github.io/zxing/apidocs/com/google/zxing/BarcodeFormat.html).\n\nThe `decode()` method accepts an image path or [PIL Image object](https://pillow.readthedocs.io/en/stable/reference/Image.html) (or list thereof)\nand takes optional parameters `try_harder` (boolean), `possible_formats` (list of formats to consider), and `pure_barcode` (boolean).\nIf no barcode is found, it returns a `False`-y `BarCode` object with all fields except `path` set to `None`.\nIf it encounters any other recognizable error from the Java ZXing library, it raises `BarCodeReaderException`.\n\n## Command-line interface\n\nThe command-line interface can decode images into barcodes and output in either a human-readable or CSV format:\n\n```\nusage: zxing [-h] [-c] [--try-harder] [--pure-barcode] [-V] image [image ...]\n```\n\nHuman-readable:\n\n```sh\n$ zxing /tmp/barcode.png\n/tmp/barcode.png\n================\n  Decoded TEXT barcode in QR_CODE format.\n  Raw text:    'Testing 123'\n  Parsed text: 'Testing 123'\n```\n\nCSV output (can be opened by LibreOffice or Excel):\n\n```sh\n$ zxing /tmp/barcode1.png /tmp/barcode2.png /tmp/barcode3.png\nFilename,Format,Type,Raw,Parsed\n/tmp/barcode1.png,CODE_128,TEXT,Testing 123,Testing 123\n/tmp/barcode2.png,QR_CODE,URI,http://zxing.org,http://zxing.org\n/tmp/barcode3.png,QR_CODE,TEXT,\"This text, \"\"Has stuff in it!\"\" Wow\u23ceYes it does!\",\"This text, \"\"Has stuff in it!\"\" Wow\u23ceYes it does!\"\n```\n\n## License\n\nLGPLv3\n",
    "bugtrack_url": null,
    "license": "LGPL v3 or later",
    "summary": "Wrapper for decoding/reading barcodes with ZXing (Zebra Crossing) library",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "https://github.com/dlenski/python-zxing"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a7ac2a004e63cd205900191a189028762c2e9b39e2c95f8e0f6fa50626612ac3",
                "md5": "f097165a2c139480fc0577412ec1593f",
                "sha256": "5a6da4365061e46364b46046ab6f19f6dcf646f35375fff311763231832f6fd4"
            },
            "downloads": -1,
            "filename": "zxing-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "f097165a2c139480fc0577412ec1593f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 689587,
            "upload_time": "2024-04-06T20:36:43",
            "upload_time_iso_8601": "2024-04-06T20:36:43.239475Z",
            "url": "https://files.pythonhosted.org/packages/a7/ac/2a004e63cd205900191a189028762c2e9b39e2c95f8e0f6fa50626612ac3/zxing-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-06 20:36:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dlenski",
    "github_project": "python-zxing",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "zxing"
}
        
Elapsed time: 0.83234s