Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heuer/segno
Python QR Code and Micro QR Code encoder
https://github.com/heuer/segno
barcode iso-18004 matrix-barcode micro-qr-code micro-qrcode python python-qrcode qr-code qr-generator qrcode segno structured-append
Last synced: about 15 hours ago
JSON representation
Python QR Code and Micro QR Code encoder
- Host: GitHub
- URL: https://github.com/heuer/segno
- Owner: heuer
- License: bsd-3-clause
- Created: 2016-08-04T09:08:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-05-15T21:59:18.000Z (7 months ago)
- Last Synced: 2024-10-29T15:12:56.995Z (about 1 month ago)
- Topics: barcode, iso-18004, matrix-barcode, micro-qr-code, micro-qrcode, python, python-qrcode, qr-code, qr-generator, qrcode, segno, structured-append
- Language: Python
- Homepage: https://pypi.org/project/segno/
- Size: 3.21 MB
- Stars: 623
- Watchers: 14
- Forks: 54
- Open Issues: 16
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - segno - Python QR Code and Micro QR Code encoder (Python)
README
QR Code encoder and Micro QR Code encoder
=========================================Pure Python QR Code generator with no dependencies.
This package implements ISO/IEC 18004:2015(E) "QR Code bar code symbology
specification" and produces QR Codes and Micro QR Codes with nearly no effort.
It supports the `Structured Append mode `_
which splits a message across several QR codes.Segno (Italian for "sign" / "symbol") provides several serialization formats
like Scalable Vector Graphics (SVG), Encapsulated PostScript (EPS),
Portable Network Graphics (PNG), Portable Document Format (PDF), Netpbm (PAM, PBM, PPM),
LaTeX (PGF/TikZ), X PixMap (XBM), and X Bitmap (XPM) etc.
None of these serializers require an external lib.
Further, it provides several high level functions to create QR Codes which encode
`contact data (vCard, MeCard) `_,
`EPC QR Codes `_,
or `WIFI QR Codes `_.The project provides more than 1500 test cases (coverage >= 98%) to verify a
standard conform QR Code and Micro QR Code generation acc. to ISO/IEC 18004:2015(E).Unique features
---------------
* Pure Python QR Code generator
* No dependencies
* A lot of `serialization formats `_ (SVG, PNG, EPS, PDF, ...)
* `Fastest (pure Python) QR Code encoder `_
* Micro QR Codes
* `Structured Append mode `_
* `Hanzi mode `_
* `Command line interface `_
* `Simple, user-friendly API `_.. code-block:: python
import segno
qrcode = segno.make('Yellow Submarine')
qrcode.save('yellow-submarine.png')* `Colorful QR codes `_
.. image:: https://github.com/heuer/segno/raw/master/docs/_static/colorful/qrcode_yellow-submarine.png
:alt: Colorful 7-H QR code encoding "Yellow Submarine"... works also with Micro QR codes
.. image:: https://github.com/heuer/segno/raw/master/docs/_static/colorful/micro_qrcode_rain.png
:alt: Colorful M4-Q Micro QR code encoding "Rain"* `Artistic QR Codes `_
(requires the `qrcode-artistic `_ plug-in).. image:: https://github.com/heuer/segno/raw/master/docs/_static/artistic/letitbe.jpg
:alt: Animated 3-H QR code encoding "The Beatles -- Let It Be"... animated QR codes are supported as well
.. image:: https://github.com/heuer/segno/raw/master/docs/_static/artistic/abbey-road.webp
:alt: Animated 4-H QR code encoding "The Beatles -- Abbey Road"Installation
------------Use ``pip`` to install segno from PyPI::
$ pip install segno
conda-forge
^^^^^^^^^^^The library is also available at `conda-forge `_
(`conda-forge project page `_)::$ conda install -c conda-forge segno
Debian
^^^^^^::
$ apt-get install python3-segno
Arch Linux
^^^^^^^^^^::
$ pacman -S python-segno
Usage
-----Command line
^^^^^^^^^^^^The command line script prints a QR code to the terminal::
$ segno "Comfortably Numb"
To serialize a QR code, use the "output" argument::
$ segno -o=raincoat.svg "Famous Blue Raincoat"
$ segno --scale 10 --dark darkblue --border 0 --output=fire.svg "Who by Fire"
$ segno --scale 10 --light transparent --output=miracle.png "Waiting for the Miracle"Library
^^^^^^^.. code-block:: python
>>> import segno
>>> # Let Segno choose the minimal version and an optimal (maximal) error
>>> # level without changing the minimal version
>>> qrcode = segno.make('Up Jumped the Devil')
>>> qrcode.designator # Returns the QR code version and the error correction level
'2-Q'
>>> qrcode.save('up-jumped-the-devil.png') # Save as PNG
>>> qrcode.save('up-jumped-the-devil-2.png', scale=10) # Scaling factor 10
>>> qrcode.save('up-jumped-the-devil-3.png', light=None) # Transparent light modules
>>> qrcode.save('up-jumped-the-devil.pdf', scale=10) # Save as PDF
>>> # SVG drawing the dark modules in "dark blue"
>>> qrcode.save('up-jumped-the-devil.svg', scale=10, dark='darkblue')If the content to encode is small enough, a Micro QR code is generated:
.. code-block:: python
>>> import segno
>>> qrcode = segno.make('RAIN')
>>> qrcode.is_micro
True
>>> qrcode.designator
'M2-M'If this behaviour is not desired, the user may set ``micro`` to ``False``
.. code-block:: python
>>> import segno
>>> qrcode = segno.make('RAIN', micro=False)
>>> qrcode.is_micro
False
>>> qrcode.designator
'1-H'Or use the factory functions ``segno.make_qr()`` which generates always QR codes
(never Micro QR codes) or ``segno.make_micro()`` which returns always
Micro QR codes (or raises an error if the content is too large for a Micro QR code)... code-block:: python
>>> import segno
>>> qrcode_micro = segno.make_micro('THE BEATLES')
>>> qrcode_micro.designator
'M3-M'
>>> qrcode = segno.make_qr('THE BEATLES') # Same content but enforce a QR Code
>>> qrcode.designator
'1-Q'
>>> # This won't work since the data does not fit into a Micro QR Code M1 - M4
>>> micro_qrcode = segno.make_micro('Nick Cave and the Bad Seeds')
Traceback (most recent call last):
...
DataOverflowError: Data too large. No Micro QR Code can handle the provided dataAll factory functions use the same parameters to specify the desired error
level, version, data mask etc., see `Segno's documentation`_ for details.Documentation
-------------
Read the online documentation atTrademark
---------
"QR Code" and "Micro QR Code" are registered trademarks of DENSO WAVE INCORPORATED... _Segno's documentation: https://segno.readthedocs.io/