Skip to main content

An advanced QR code generator with multiple data type support

Project description

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

  1. Clone the repository:
git clone https://github.com/GamingOP69/qrcodex.git
cd qrcodex
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # Linux/macOS
venv\Scripts\activate     # Windows
  1. 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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run the tests (pytest)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to your branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Support

If you encounter any issues or have questions:

  1. Check the documentation
  2. Open an issue
  3. Contact the maintainers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qrcodex-0.1.1.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qrcodex-0.1.1-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file qrcodex-0.1.1.tar.gz.

File metadata

  • Download URL: qrcodex-0.1.1.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for qrcodex-0.1.1.tar.gz
Algorithm Hash digest
SHA256 baa1cbae6978fd644f58ce9d0895a29a2a642c17e6b76199c0af0ec91af5ae96
MD5 92df0d14ab8f00111422ba970a47fcf3
BLAKE2b-256 15bf340b1d7fe920c8a2e5ee062799ca3bf4426f4ba40fd385931300df9d0075

See more details on using hashes here.

File details

Details for the file qrcodex-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: qrcodex-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for qrcodex-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80e78ab19e3891648ac80672d9e480dae96086ff1bc287e3768f4294dafaa028
MD5 3c197eaca349d82e509624e11a5104bd
BLAKE2b-256 abf4e67ea9b57527d8c13ff42ad01e5b7552df60202ba380aef1d279f7e4d110

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page