Package: segno
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 theStructured Append modewhich 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 encodecontact data (vCard, MeCard),EPC QR Codes,
orWIFI 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 featuresPure Python QR Code generatorNo dependenciesA lot ofserialization formats(SVG, PNG, EPS, PDF, …)Fastest (pure Python) QR Code encoderMicro QR CodesStructured Append modeHanzi modeCommand line interfaceSimple, user-friendly APIimportsegnoqrcode=segno.make('Yellow Submarine')qrcode.save('yellow-submarine.png')Colorful QR codes… works also with Micro QR codesArtistic QR Codes(requires theqrcode-artisticplug-in)… animated QR codes are supported as wellInstallationUsepipto install segno from PyPI:$ pip install segnoMacPortsSegno is also available atMacPorts(MacPorts project page):$ sudo port install py-segnoconda-forgeThe library is also available atconda-forge(conda-forge project page):$ conda install -c conda-forge segnoDebian$ apt-get install python3-segnoDebian 10 / Buster (backports)$ apt-get -t buster-backports install python3-segnoArch Linux$ pacman -S python-segnoUsageCommand lineThe 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>>>importsegno>>># 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:>>>importsegno>>>qrcode=segno.make('RAIN')>>>qrcode.is_microTrue>>>qrcode.designator'M2-M'If this behaviour is not desired, the user may setmicrotoFalse>>>importsegno>>>qrcode=segno.make('RAIN',micro=False)>>>qrcode.is_microFalse>>>qrcode.designator'1-H'Or use the factory functionssegno.make_qr()which generates always QR codes
(never Micro QR codes) orsegno.make_micro()which returns always
Micro QR codes (or raises an error if the content is too large for a Micro QR code).>>>importsegno>>>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(mostrecentcalllast):...DataOverflowError:Datatoolarge.NoMicroQRCodecanhandletheprovideddataAll factory functions use the same parameters to specify the desired error
level, version, data mask etc., seeSegno’s documentationfor details.DocumentationRead the online documentation at <https://segno.readthedocs.io/>Trademark“QR Code” and “Micro QR Code” are registered trademarks of DENSO WAVE INCORPORATED.