lincolnloop / python-qrcode

Python QR Code image generator
https://pypi.python.org/pypi/qrcode
Other
4.36k stars 666 forks source link

Make it possible to pass in other supported color types, e.g. RGB tup… #182

Closed cbalfour closed 3 years ago

cbalfour commented 4 years ago

At the moment the code assumes that color values will be strings. This limits the range of colors that can be used. Trying to pass an RGB tuple raises an exception on the string methods used.

By performing the string methods earlier and catching and ignoring the exceptions, other data structures can quietly pass through to Image.new() to be accepted if supported, or to raise an exception.

Ideally, PilImage should be color type agnostic and convert all values to some common color type to make the code as flexible as possible.