QRCode XColor
Note: This does not work with the qrcode version 7.3.1 in pypi. pypi will not allow git sources in the setup.py requirments so mush be manually installed
Install qrcode from master branch
pip install git+https://github.com/lincolnloop/python-qrcode.git@8a37658d68dae463479ee88e96ee3f1f53a16f54
This library recreates a few of the moduledrawers classes already found in https://github.com/lincolnloop/python-qrcode.
This was done to greatly speed up the generation of creating colored qrcodes, as well as supporting for different colors and styles for the location marker in the corners.
Using these custom classes you do lose support for the full features of the color_mask argument in the original QRCode library like having the colors be a gradient across the qrcode.
I chose for speed over having that feature with still getting full color and transparency support of the qrcode.
All supported module drawers:
from qrcode_xcolor import (
XStyledPilImage,
XSquareModuleDrawer,
XGappedSquareModuleDrawer,
XCircleModuleDrawer,
XRoundedModuleDrawer,
XVerticalBarsDrawer,
XHorizontalBarsDrawer
)
Here are some examples of the speed difference:
import time
import qrcode
from qrcode.image.styledpil import StyledPilImage
from qrcode.image.styles.moduledrawers import GappedSquareModuleDrawer, RoundedModuleDrawer
from qrcode.image.styles.colormasks import SolidFillColorMask
from qrcode_xcolor import XStyledPilImage, XGappedSquareModuleDrawer, XRoundedModuleDrawer
st = time.time()
qr = qrcode.QRCode()
qr.add_data("https://example.com")
img = qr.make_image(
image_factory=StyledPilImage,
color_mask=SolidFillColorMask(
front_color=(59, 89, 152),
back_color=(255, 255, 255),
),
module_drawer=GappedSquareModuleDrawer(),
eye_drawer=RoundedModuleDrawer(),
embeded_image_path='docs/gitlab.png',
)
img.save("qrcode_color_mask.png")
print(f"qrcode color_mask: {time.time() - st:.4f}s")
st = time.time()
qr = qrcode.QRCode()
qr.add_data("https://example.com")
# The 4th value in all the colors is the opacity the color should use (0=clear <--> 255=solid)
img = qr.make_image(
# Custom image factory
image_factory=XStyledPilImage,
back_color=(255, 255, 255, 255), # Background color with opacity support
module_drawer=XGappedSquareModuleDrawer(
front_color=(59, 89, 152, 255),
),
eye_drawer=XRoundedModuleDrawer(
front_color=(255, 110, 0, 255),
inner_eye_color=(65, 14, 158, 255), # Only valid with the eye_drawer
),
embeded_image_path='docs/gitlab.png', # Still supports embedding logos in the middle
)
img.save("qrcode-xcolor.png")
print(f"qrcode-xcolor: {time.time() - st:.4f}s")
From this test we get the results (exact timings will vary but the difference is always there):
qrcode color_mask: 0.5071s
qrcode-xcolor: 0.0430s
Metadata
Release files for qrcode-xcolor 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qrcode-xcolor-0.1.1.tar.gz | 6.5 kB | Without provenance | Details for qrcode-xcolor-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qrcode_xcolor-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for qrcode_xcolor-0.1.1-py3-none-any.whl |
Total release size: 13.3 kB
Release files / qrcode-xcolor-0.1.1.tar.gz
| Download URL | qrcode-xcolor-0.1.1.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7dfbf971b3b2f593261a51db477c12ac6ac17f360572bed012f346fce94f2b5f
|
|
BLAKE2b-256 checksum How to use checksums |
88f6610fbf13f4861195d5452ed741194a5e464b028f62bd9e6ae899c4a69982
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / qrcode_xcolor-0.1.1-py3-none-any.whl
| Download URL | qrcode_xcolor-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c19ce53c5a54087b8cede6b992ca4e362552e49f81d1969f98ababb2952a6bf3
|
|
BLAKE2b-256 checksum How to use checksums |
a04ae2a93b30cf673545005b9143ff461cacc24bbd0d412d16e338dfbd80f381
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Security for qrcode-xcolor 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.