
Security News
The Nightmare Before Deployment
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.
custom-qr
Advanced tools
The custom_qr library enables the generation and customization of QR codes with various options.




pip install custom_qr
pip list
Note: It is recommended to use a virtual environment.
from custom_qr import QrCode
from custom_qr import (
ERROR_CORRECTION_LEVEL_H,
ERROR_CORRECTION_LEVEL_Q,
ERROR_CORRECTION_LEVEL_M,
ERROR_CORRECTION_LEVEL_L
)
Note: Error correction level constants are optional. 2. Create a QR Code:
qr = QrCode()
matrix, version = qr.generate("https://www.qrcode.com/")
To specify a version and/or error correction level:
qr = QrCode()
matrix, version = qr.generate("https://www.qrcode.com/", version=6, error_correction=ERROR_CORRECTION_LEVEL_Q)
Q (recovers 25% of data).
qr.print_qr_console(matrix)
Note: Console output is not scannable. 4. Get Image Version:
img = qr.create_qr_image(matrix)
qr.display_qr(img)
qr.create_image_file(img, filename="qr.png")
Note: Default filename is "qr.png".
Color Usage in QR Codes
Test QR codes with various devices to ensure scannability.
background = (255, 255, 255)
qr.create_qr_image(matrix, background)
block_style = {
"size": 10,
"type": 0,
"color": [(0, 0, 0), (255, 0, 0)] # Black and Red
}
qr.create_qr_image(matrix, block_style)
block_style = {
"size": 10,
"type": 1, # Circular
"color": [(0, 0, 0), (255, 0, 0)] # Black and Red
}
qr.create_qr_image(matrix, block_style)
finder_style = {"color": (0, 0, 0)}
qr.create_qr_image(matrix, finder_style)
alignment_style = {"color": (0, 0, 0)}
qr.create_qr_image(matrix, alignment_style)
Overlay custom text on the QR code, but be mindful of potential readability issues:
Example:
text_style = {
"color": (6, 123, 194),
"size": "small",
"bot": 10,
"left": 3,
"orientation": 0
}
text = "CUSTOM"
img = qr.create_qr_image(matrix)
qr.write_text(img, text, text_style, background, block_style["size"])
Write from Right:
text_style = {
"color": (6, 123, 194),
"size": "small",
"bot": 10,
"left": 30, # Left margin has to be greater than text width
"orientation": 1 # Adjusted to write from right
}
text = "CUSTOM"
img = qr.create_qr_image(matrix)
qr.write_text(img, text, text_style, background, block_style["size"])
Note: Use higher versions and error correction levels to maintain validity when adding text. If the text is too large, write_text() will return None.
FAQs
Generate and customize QR codes
We found that custom-qr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.

Research
/Security News
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.