PIL/Pillow writer 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.3 – 2016-08-14
Initial release
0.1.1 – 2016-08-14
Unreleased
0.1.0 – 2016-08-14
Unreleased
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for segno_pil-0.1.3-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a37d598f8dab3bac042b8e8b925c099e4311977e2e73f90802b884141556c23f |
|
MD5 | 795a75355d76fa2a51e81c74387c840e |
|
BLAKE2b-256 | 4c7f306b8b2e717a79bca57b199b834515c5b42e2a27fabfb23cf42a64b29ce5 |