Open Liscuri opened 1 year ago
I also noticed that it doesn't work if I use "image_factory=StyledPilImage" apart from that "fill_color" and "back_color" WORKS NORMALLY!
I'm facing the same issue as well.
import qrcode
from qrcode.image.styledpil import StyledPilImage
from qrcode.image.styles.moduledrawers.pil import CircleModuleDrawer
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_M,
box_size=10,
border=0,
)
qr.add_data('Some text')
qr.make(fit=True)
img = qr.make_image(
fill_color="red",
back_color="blue",
image_factory=StyledPilImage,
module_drawer=CircleModuleDrawer()
)
img.save('./data/qrcode_test.png')
Python 3.11.4
Package Version
----------------- ------------
qrcode 7.4.2
I'm also facing this issue. Here is a very minimum example where I am seeing only black and white QR codes being made:
import qrcode
qr = qrcode.QRCode(version = 1, box_size = 10, border = 4)
qr.add_data("myQR")
qr.make(fit = True)
img = qr.make_image(fill_color = 'red', back_color = 'white')
img.save("myQR.png")
Here is the output:
I'm using Python 3.11.0 and qrcode 7.4.2
The only option to get a QRcode with custom colors is to use color_mask=SolidFillColorMaks(back_color=(R,G,B), front_color=(R,G,B)
in the way described in README.
But SolidFillColorMask()
works as post-make filter and doesn't send user color set to make_image
, according to the logic of this package make_image
method makes QRcode in black and white by default, then gets generated QR image and changes pixel-by-pixel default (black and white) color set to custom. Such attitude takes a lot of time and resources, in my case it takes less then 0,5 seconds to generate a QR and up to 15 seconds to change colors with SolidFillColorMask()
The best way is to clone repo and make changes in make_image
method (and others) so it takes custom colors if they set by user .
I'm also facing this issue. Here is a very minimum example where I am seeing only black and white QR codes being made:
import qrcode qr = qrcode.QRCode(version = 1, box_size = 10, border = 4) qr.add_data("myQR") qr.make(fit = True) img = qr.make_image(fill_color = 'red', back_color = 'white') img.save("myQR.png")
Here is the output:
I'm using Python 3.11.0 and qrcode 7.4.2
Install Pillow
It doesn't work in the recent versions. I know it works on older version but would prefer using the newest version for my code.