Colorful QR Codes¶
Almost all serializers support custom settings for the color of the dark and light modules of a (Micro) QR code.
The color values can be provided as tuple (R, G, B)
, as web color name
(like ‘red’) or as hexadecimal #RRGGBB
value (i.e. ‘#085A75’). If alpha
transparency is supported (i.e. PNG and SVG),
hexadecimal values like #RRGGBBAA
are accepted.
The value None
is accepted by many serialization formats and indicates
transparency, i.e. light=None
indicates that all light modules should
be transparent.
In almost all cases the color values are automatically converted into a meaningful value of the specific output format.
The keywords are optional, if not provided, all serializers use reasonable default values (dark modules are rendered in black, light modules in white).
Note
Providing an alpha channel to a serializer which does not accept an alpha channel results usually into an error.
The SVG, PNG and PPM serializers support more than two colors, every module type may have its own color.
>>> import segno
>>> qrcode = segno.make('Yellow Submarine', version=7, error='h')
>>> qr.save('qrcode_yellow-submarine.png', scale=4, dark='darkred',
... data_dark='darkorange', data_light='yellow')

>>> import segno
>>> micro_qrcode = segno.make('Rain', error='q')
>>> micro_qrcode.save('micro_qrode_rain.png', scale=4, dark='darkblue', data_dark='steelblue')

Module names¶
The following examples show the results of all supported module types. The unaffected modules are rendered as grey or white modules, the red modules show the result of the keyword.
The keywords “dark” and “light” (at the command line --dark
and --light
) are supported by almost all serialization
formats.
alignment_dark / --align-dark
¶
Sets the color of the dark alignment pattern modules.
Micro QR Codes don’t have alignment patterns.


alignment_light / --align-light
¶
Sets the color of the light alignment pattern modules.
Micro QR Codes don’t have alignment patterns.


dark_module / --dark-module
¶
Sets the color of the dark module.
Micro QR Codes don’t have a dark module.


version_dark / --version-dark
¶
Sets the color of the dark modules of the version information.
Micro QR Codes and QR Codes lesser than version 7 don’t carry any version information.


version_light / --version-light
¶
Sets the color of the light modules of the version information.
Micro QR Codes and QR Codes lesser than version 7 don’t carry any version information.

