Skip to main content

PIL/Pillow plugin for the Segno (Micro) QR Code generator

Project description

Segno PIL – Segno plugin for creating PIL/Pillow images from QR Codes

This Segno plugin converts a (Micro) QR Code to a PIL/Pillow Image.

This plugin is not required to write PNG, EPS or PDF files. Segno’s native implementations usually generate smaller files in less time. This plugin might be useful to modify the QR Codes (i.e. rotate or blur) or to save the QR Codes in an image format which is not supported by Segno.

The resulting image is either a greyscale (PIL mode “1”), an indexed-color image (PIL mode “P”) or an RGBA image. The mode depends on the provided (background) color values. The plugin chooses the optimal (minimal) mode automatically. Use the mode parameter to enforce a specific mode. Mode “RGB” is not supported, though.


>>> import segno
>>> qr = segno.make('Hello world')
>>> pil_img = qr.to_pil()  # Greyscale image, default scale
>>> qr.to_pil(scale=10).show()  # Show img with scale 10
>>> # Different scale
>>> pil_img = qr.to_pil(scale=10)
>>> # Different scale and change module color
>>> pil_img = qr.to_pil(scale=10, color='darkblue')  # Indexed-color image
>>> # Different scale and change module color and transparent background
>>> pil_img = qr.to_pil(scale=10, color='#36c', background=None)
>>> # transparency = 0 means that the first color in the palette should be
>>> # transparent. The background color is ALWAYS the first entry in the palette
>>>'example-4.png', transparency=0)
>>> # Different scale and change module color and yellow background
>>> # Enforce 'RGBA' mode since 'P' isn't supported by JPEG even if no color
>>> # uses the alpha channel
>>> qr.to_pil(scale=10, color='#36c', background='yellow', mode='RGBA').save('example-4.jpg')
>>> rotated_img = pil_img.rotate(45, expand=True)
>>> rotated_img.convert('RGB').save('example-5.jpg')


0.1.6 – 2016-09-19

  • Fixed Python packaging

0.1.5 – 2016-08-24

  • Adapt Segno’s 0.1.6 API changes.

0.1.4 – 2016-08-16

  • Updated docs

0.1.3 – 2016-08-14

  • Initial release

Project details

Download files

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

Files for segno-pil, version 0.1.6
Filename, size File type Python version Upload date Hashes
Filename, size segno_pil-0.1.6-py2.py3-none-any.whl (6.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size segno-pil-0.1.6.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page