|
Project Information
|
ElapheWARNING! trunk is broken for complete rewriting. For working version, grab 0.5.3 in /tags. Elaphe is a python binding for the Barcode Writer In Pure PostScript (http://www.terryburton.co.uk/barcodewriter/). It is a thin-wrapper which employs Python Imaging Library as PostScript rendering interface. Requirements
generator expressions are used).
(http://www.pythonware.com/products/pil) is required under the condition that EpsImagePlugin is enabled (i.e. at least you must have Ghostscript is installed and callable from PIL). Simple UsageThe following example:
>>> from elaphe import barcode
>>> barcode('qrcode',
... 'Hello Barcode Writer In Pure PostScript.',
... options=dict(version=9, eclevel='M'),
... margin=10, data_mode='8bits')) # Generates PIL.EpsImageFile instance
<PIL.EpsImagePlugin.EpsImageFile instance at ...>
>>> _.show() # Show the imageshould invoke default viewer which shows a QRcode symbol with 10px margin. Remember, barcode() returns PIL image object. Frequently Issued ProblemsTrunk does not workNo problem, trunk is broken. Use /tags/0.5.3. IOError: 32 Broken pipeIf you see, especially on Windows, something like: File ".../PIL/EpsImagePlugin.py", line 72, in Ghostscript
gs.write(s)
IOError: [Errno 32] Broken pipeMake sure Ghostscript is installed as well as environment variable PATH is set. Try following code on your enviroment: # coding: utf-8
from StringIO import StringIO
from PIL.EpsImagePlugin import EpsImageFile
src = """%!PS-Adobe 2.0
%%BoundingBox: 0 0 144 144
36 36 72 72 rectfill
/Courier findfont 12 scalefont setfont
36 120 moveto (text) show
showpage
"""
im = EpsImageFile(StringIO(src))
im.save('foo.png')If PIL and Ghostscript are correctly installed, you will see square and text in 'foo.png'. PlanElaphe will make use of reportlab.graphics.renderFooBar instead of bwipp/gs/PIL. |