lincolnloop / python-qrcode

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

Change fill_color while using image_factory #239

Open marcofucito opened 2 years ago

marcofucito commented 2 years ago

Hello, how can i change the the fill_color when using an image factory?

I have tried with the following two commands, but if I use the image factory, the fill_color command seems to be ignored:

img = qr.make_image(image_factory=StyledPilImage, fill_color=(255, 0, 0), embeded_image_path="test.png") img = qr.make_image(image_factory=StyledPilImage, fill_color="red", embeded_image_path="test.png")

Thank you

zigarn commented 2 years ago

Workaround is to explicitly use SolidFillColorMask with front_color = the fill color:

img = qr.make_image(
  image_factory=StyledPilImage,
  module_drawer=SolidFillColorMask(front_color=(255, 0, 0)),
  embeded_image_path="test.png"
)

img = qr.make_image(
  image_factory=StyledPilImage,
  module_drawer=SolidFillColorMask(front_color="red"),
  embeded_image_path="test.png"
)