🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

qrcodex

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qrcodex

An advanced QR code generator with multiple data type support

0.1.1
PyPI
Maintainers
1

QRCodeX - Advanced QR Code Generator

A modern Python library for generating QR codes with support for multiple data types, custom styling, and various output formats.

Features

  • Multiple data types support:
    • Text (auto-detects numeric and alphanumeric modes)
    • URLs (auto-detected)
    • Images (PNG, JPEG, etc. converted to data URIs)
    • Binary data (automatically encoded)
  • Custom styling:
    • Custom colors (hex, RGB, named colors)
    • Adjustable size and border
    • Error correction levels (L, M, Q, H)
  • Multiple output formats:
    • PNG (with transparency support)
    • SVG (scalable vector graphics)
    • PDF (coming soon)
  • Modern Python features:
    • Type hints for better IDE support
    • Path handling with pathlib
    • Comprehensive error handling
    • CLI interface (coming soon)

Installation

From PyPI

pip install qrcodex

From Source

git clone https://github.com/GamingOP69/qrcodex.git
cd qrcodex
pip install -e .

Development Installation

git clone https://github.com/GamingOP69/qrcodex.git
cd qrcodex
pip install -r requirements.dev.txt
pip install -e .

Usage

Basic Usage

from qrcodex import QRCodeX

# Create a simple text QR code
qr = QRCodeX()
qr.add_data("Hello, World!")
qr.generate("output.png")

# Create a URL QR code (automatically detected)
qr = QRCodeX()
qr.add_data("https://example.com")  # Automatically detected as URL
qr.generate("url.png")

Advanced Usage

from qrcodex import QRCodeX
from pathlib import Path

# Create a QR code with custom settings
qr = QRCodeX(
    error_correction='H',    # Highest error correction
    box_size=10,            # Pixel size of each module
    border=4,               # Border size
    version=None           # Auto version selection
)

# Add multiple types of data
qr.add_data("https://example.com", data_type='url')
qr.add_data(Path("image.png"), data_type='image')
qr.add_data(bytes([0x00, 0xFF]), data_type='binary')

# Generate with custom colors
qr.generate(
    "output.svg",
    fill_color="#FF0000",    # Red QR code
    back_color="white",      # White background
    format="svg"            # SVG output
)

Error Correction Levels

  • L (Low) - 7% of data can be restored
  • M (Medium) - 15% of data can be restored
  • Q (Quartile) - 25% of data can be restored
  • H (High) - 30% of data can be restored
# High error correction for better reliability
qr = QRCodeX(error_correction='H')
qr.add_data("Important data")
qr.generate("reliable.png")

Image QR Codes

from qrcodex import QRCodeX
from pathlib import Path

# Convert image to QR code
qr = QRCodeX(error_correction='M')
qr.add_data(Path("logo.png"), data_type='image')
qr.generate("image_qr.png")

# Use existing data URI
data_uri = "data:image/png;base64,..."
qr.add_data(data_uri, data_type='image')
qr.generate("uri_qr.png")

Binary Data

# Create QR code with binary data
binary_data = bytes([0x00, 0xFF, 0xAA, 0x55])
qr = QRCodeX()
qr.add_data(binary_data, data_type='binary')
qr.generate("binary.png")

Development

Setup Development Environment

  • Clone the repository:
git clone https://github.com/GamingOP69/qrcodex.git
cd qrcodex
  • Create a virtual environment:
python -m venv venv
source venv/bin/activate  # Linux/macOS
venv\Scripts\activate     # Windows
  • Install development dependencies:
pip install -r requirements.dev.txt

Running Tests

# Run all tests
pytest

# Run with coverage report
pytest --cov=qrcodex

# Run specific test file
pytest tests/test_generator.py

Code Style

The project uses:

  • black for code formatting
  • isort for import sorting
  • flake8 for linting
  • mypy for type checking

Run all checks:

black .
isort .
flake8 .
mypy src/qrcodex

Building

# Build distribution packages
python -m build

# Install locally for testing
pip install -e .

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes:

  • Fork the repository
  • Create a feature branch (git checkout -b feature/amazing-feature)
  • Make your changes
  • Run the tests (pytest)
  • Commit your changes (git commit -m 'Add amazing feature')
  • Push to your branch (git push origin feature/amazing-feature)
  • Open a Pull Request

Support

If you encounter any issues or have questions:

FAQs

Did you know?

Socket

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.

Install

Related posts