QR Code and Micro QR Code generator for Python
Project description
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, …)
Micro QR Codes
import segno
qrcode = segno.make('Yellow Submarine')
qrcode.save('yellow-submarine.png')
-
… works also with Micro QR codes
Artistic QR Codes (requires the qrcode-artistic plug-in)
… animated QR codes are supported as well
Installation
Use pip to install segno from PyPI:
$ pip install segno
MacPorts
Segno is also available at MacPorts (MacPorts project page):
$ sudo port install py-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
Debian 10 / Buster (backports)
$ apt-get -t buster-backports 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
>>> 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:
>>> 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
>>> 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).
>>> 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 data
All 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 at <https://segno.readthedocs.io/>
Trademark
“QR Code” and “Micro QR Code” are registered trademarks of DENSO WAVE INCORPORATED.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file segno-1.6.1.tar.gz
.
File metadata
- Download URL: segno-1.6.1.tar.gz
- Upload date:
- Size: 72.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f23da78b059251c36e210d0cf5bfb1a9ec1604ae6e9f3d42f9a7c16d306d847e |
|
MD5 | 3835036bcf44667eb0a155107ed1ac67 |
|
BLAKE2b-256 | 5d743896e205306a1b43d6b88326e5838572d97b4b74df8c9cd11acfcd9db503 |
File details
Details for the file segno-1.6.1-py3-none-any.whl
.
File metadata
- Download URL: segno-1.6.1-py3-none-any.whl
- Upload date:
- Size: 73.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e90c6ff82c633f757a96d4b1fb06cc932589b5237f33be653f52252544ac64df |
|
MD5 | e2a68bff3cf5f577b2007dc8ccdee630 |
|
BLAKE2b-256 | 277cabc460494640767edfce9c920da3e03df22327fc5e3d51c7857f50fd89c4 |