Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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.

Usage:

>>> import segno
>>> qr = segno.make('Hello world')
>>> pil_img = qr.to_pil()  # Greyscale image, default scale
>>> pil_img.save('example.png')
>>> qr.to_pil(scale=10).show()  # Show img with scale 10
>>> # Different scale
>>> pil_img = qr.to_pil(scale=10)
>>> pil_img.save('example-2.png')
>>> # Different scale and change module color
>>> pil_img = qr.to_pil(scale=10, color='darkblue')  # Indexed-color image
>>> pil_img.save('example-3.png')
>>> # 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
>>> pil_img.save('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')

Changes

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
Release History

Release History

This version
History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
segno_pil-0.1.6-py2.py3-none-any.whl (6.4 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Sep 19, 2016
segno-pil-0.1.6.tar.gz (5.3 kB) Copy SHA256 Checksum SHA256 Source Sep 19, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting