Python ctypes binding to libqrencode.
This module when ran as a script attempts to mimic the c sample program qrenc.c otherwise known as qrencode
This file is part of libqrencode python ctypes bindings.
Copyright (C) 2012 Matthew Baker <mu.beta.06@gmail.com>
This is free software: you can redistribute it and/or modify it under the terms of the LGNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the LGNU Lesser General Public License along with this software. If not, see <http://www.gnu.org/licenses/>.
Install libqrencode.
Unpack archive onto local machine.
Run
$ python setup.py install
Test
$ python -m libqrencode.qrencode 'Hello World'
XXXXXXXXXXXXXX XX XXXX XXXXXXXXXXXXXX
XX XX XXXXXX XX XX
XX XXXXXX XX XXXX XXXX XX XXXXXX XX
XX XXXXXX XX XX XX XX XXXXXX XX
XX XXXXXX XX XX XX XX XXXXXX XX
XX XX XX XX XX
XXXXXXXXXXXXXX XX XX XX XXXXXXXXXXXXXX
XXXX XXXX
XXXXXX XXXXXXXXXXXXXXXX XXXX XX
XXXX XXXX XXXXXX XXXXXX XXXX
XX XX XX XX XX XX XXXX XXXXXXXXXXXX
XX XXXXXX XX XX
XXXX XX XXXX XX XXXX XXXX
XX XXXX XX XXXX
XXXXXXXXXXXXXX XX XXXX XXXX XXXXXX
XX XX XXXX XXXX XX XX
XX XXXXXX XX XX XX XX
XX XXXXXX XX XXXXXX XXXXXX XXXX
XX XXXXXX XX XX XX XX XX XX XX XX
XX XX XX XX XX XX
XXXXXXXXXXXXXX XX XXXXXX XX XXXX
Run the following for usage
$ python -m libqrencode.qrencode -h
Usage: qrencode [OPTION]... [STRING]
libqrencode ctypes python binding version 1.0, libqrencode version 3.2.1
Options:
-h, --help show this help message and exit
-o FILENAME, --filename=FILENAME
Encoded image filename (.png, .pdf, .jpg, .tif...)
-s SIZE, --size=SIZE Specify module size in dots (pixels). (default=3)
-l LEVEL, --level=LEVEL
specify error correction level from L (lowest) to H
(highest). (default=L)
-v SYMVERSION, --symversion=SYMVERSION
specify the version of the symbol. (default=auto)
-m MARGIN, --margin=MARGIN
specify the width of the margins. (default=4)
(2 for Micro)))
-d DPI, --dpi=DPI specify the DPI of the generated PNG. (default=72)
-S, --structured make structured symbols. Version must be
specified.
-k, --kanji assume that the input text contains kanji
(shift-jis).
-c, --casesensitive encode lower-case alphabet characters in 8-bit mode.
(default)
-8, --eightbit encode entire data in 8-bit mode. -k and -c will be
ignored.
-M, --micro encode in a Micro QR Code. (experimental).
Import libqrencode bindings:
>>> from libqrencode import qrencode
Create a qrencode.QREncoder instantiation:
>>> encoder = qrencode.QREncoder()
Encode a string using the aforementioned instantiation:
>>> encoder.encode('Hello World')
Select encoded output format from one of the following output formats:
ASCII:
>>> encoder.asciipreview() XXXXXXXXXXXXXX XX XXXX XXXXXXXXXXXXXX XX XX XXXXXX XX XX XX XXXXXX XX XXXX XXXX XX XXXXXX XX XX XXXXXX XX XX XX XX XXXXXX XX XX XXXXXX XX XX XX XX XXXXXX XX XX XX XX XX XX XXXXXXXXXXXXXX XX XX XX XXXXXXXXXXXXXX XXXX XXXX XXXXXX XXXXXXXXXXXXXXXX XXXX XX XXXX XXXX XXXXXX XXXXXX XXXX XX XX XX XX XX XX XXXX XXXXXXXXXXXX XX XXXXXX XX XX XXXX XX XXXX XX XXXX XXXX XX XXXX XX XXXX XXXXXXXXXXXXXX XX XXXX XXXX XXXXXX XX XX XXXX XXXX XX XX XX XXXXXX XX XX XX XX XX XXXXXX XX XXXXXX XXXXXX XXXX XX XXXXXX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXX XX XXXXXX XX XXXXBoolean list of lists:
>>> qr_list = encoder.as2dlist()Postscript string:
>>> qr_ps = encoder.asps()
See the individual classes, methods, attributes and functions below for further details.
Base class for representing QREncode c structures. Allows for struct member read access as class attributes.
Python representation of QRcode c structure
Python representation of QRcode_List c structure.
Base class for representing QREncoder.
Largely used to maintain the state that the globals in qrenc.c represent.
Return a PostScript representation of the encoded QRCode.
Paints the “black” symbol in the current colour on the assumption that the background has already been painted and appropriate colour. Symbols are assumed to be 1 user coordinate square.
Return the QREncoder’s casesensitive property.
Return the QREncode object
Return the QREncoder’s eightbit property.
Return the QREncoder’s hint.
Return the QREncoder’s level.
Return the QREncoder’s micro property.
Return the QREncoder’s symbol version property.
Python (http://www.python.org)
libqrencode (http://fukuchi.org/works/qrencode/index.html.en)
Python Imaging Library (PIL, http://www.pythonware.com/products/pil/) (optional)