Skip to main content

QR Code and Micro QR Code generator

Project description

Segno is a QR Code and Micro QR Code generator which has no further dependencies.

This package implements main parts of ISO/IEC 18004:2006(E) / ISO/IEC 18004:2015(E) and produces Micro QR Codes and QR Codes with nearly no effort.

Segno provides several serialization formats like SVG, EPS, PNG, PDF, or text output. Neither of these serializers require an external lib. Segno provides more serialization formats via a plugin architecture. It was tested against Jython, Python 2.6 - 3.4, and PyPy.

Installation

Use pip to install segno from PyPI:

$ pip install segno

Usage

Segno provides several, specific methods which serialize the QR Code (like svg, png), but it also provides a general save() method which could be used to save a QR Code in the desired format.

>>> import segno
>>> qr = segno.make('Up Jumped the Devil')  # Let Segno choose the minimal version
>>> qr.is_micro
False
>>> qr.version
2
>>> qr.error
'M'
>>> qr.save('up-jumped-the-devil.png')  # Save as PNG
>>> qr.save('up-jumped-the-devil-2.png', scale=10)  # Scaling factor 10
>>> qr.save('up-jumped-the-devil-3.png', background=None)  # Transparent background
>>> qr.save('up-jumped-the-devil.pdf', scale=10)  # Save as PDF
>>> # SVG drawing the dark modules in "dark blue"
>>> qr.save('up-jumped-the-devil.svg', scale=10, color='darkblue')

If the content to encode is small enough, a Micro QR Code is generated:

>>> import segno
>>> qr = segno.make('RAIN')
>>> qr.is_micro
True
>>> qr.version
'M2'

If this behaviour is not desired, the user may use the factory functions segno.make_qr() which generates always QR Codes (never Micro QR Codes) or segno.make_micro() which generates always Micro QR Codes (or raises an error if the content is too large for a Micro QR Code).

>>> import segno
>>> mqr = segno.make_micro('THE BEATLES')
>>> mqr.version
'M3'
>>> qr = segno.make_qr('THE BEATLES')  # Same content but enforce a QR Code
>>> qr.version
1
>>> # This won't work since the data does not fit into a Micro QR Code M1 - M4
>>> mqr = 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.

Other QR Code generators

0.1.1 – 2016-08-14

  • Initial release

0.1.0 – 2016-08-14

  • Unreleased

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

segno-0.1.1.tar.gz (43.6 kB view hashes)

Uploaded Source

Built Distribution

segno-0.1.1-py2.py3-none-any.whl (46.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page