qr-code-generator-cli 1.0.0
Generate QR codes with customizable colors in PNG and SVG formats
Requires Python: >=3.8
Keywords: cli, generator, png, qr, qr-code, qrcode, svg

# QR Code Generator

[![PyPI version](https://img.shields.io/pypi/v/qr-code-generator-cli.svg)](https://pypi.org/project/qr-code-generator-cli/)
[![Python versions](https://img.shields.io/pypi/pyversions/qr-code-generator-cli.svg)](https://pypi.org/project/qr-code-generator-cli/)
[![License](https://img.shields.io/pypi/l/qr-code-generator-cli.svg)](https://github.com/nabilragab/qrgen/blob/main/LICENSE)

A simple, fast QR code generator with customizable colors. Outputs PNG or SVG with transparent backgrounds.

## Features

- Generate QR codes in **PNG** or **SVG** format
- Customizable foreground color (hex format)
- Transparent background support
- Configurable size and border
- Simple CLI and Python API

## Installation

```bash
pip install qr-code-generator-cli
```

Or install from source:

```bash
git clone https://github.com/nabilragab/qrgen.git
cd qrgen
pip install .
```

## Quick Start

### Command Line

```bash
# Generate a white QR code (default)
qrgen "https://example.com"

# Generate an SVG
qrgen "https://example.com" --output qr.svg

# Custom color
qrgen "https://example.com" --fg-color "#0000FF" --output blue.svg
```

### Python API

```python
from qr_code_generator import create_qr_code

# Basic usage
create_qr_code("https://example.com", "qr.png")

# SVG with custom color
create_qr_code("https://example.com", "qr.svg", fg_color="#FF5733")

# With all options
create_qr_code(
    data="https://example.com",
    output_file="custom.svg",
    fg_color="#694585",
    box_size=15,
    border=2,
)
```

## CLI Reference

```
usage: qrgen [-h] [-o OUTPUT] [-c COLOR] [--box-size SIZE] [--border SIZE] [-v] data

Generate QR codes with customizable colors in PNG and SVG formats.

positional arguments:
  data                  Data to encode in the QR code (URL, text, etc.)

options:
  -h, --help            show this help message and exit
  -o, --output OUTPUT   Output file path (default: qrcode.png)
  -c, --fg-color COLOR  Foreground color in hex format (default: "#FFFFFF")
  --box-size SIZE       Size of each box in the QR code (default: 10)
  --border SIZE         Border size around the QR code (default: 4)
  -v, --version         show program's version number and exit
```

## API Reference

### `create_qr_code(data, output_file, fg_color="#FFFFFF", box_size=10, border=4)`

Generate a QR code with customizable options.

**Parameters:**

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `data` | `str` | required | Data to encode (URL, text, etc.) |
| `output_file` | `str` | required | Output path (`.png` or `.svg`) |
| `fg_color` | `str` | `"#FFFFFF"` | Foreground color in hex format |
| `box_size` | `int` | `10` | Size of each QR code module |
| `border` | `int` | `4` | Border size (minimum 4 per spec) |

**Returns:** `str` - Path to the generated file.

## Examples

### Generate QR codes for different use cases

```bash
# Website URL
qrgen "https://mywebsite.com" -o website.svg

# WiFi credentials (standard format)
qrgen "WIFI:T:WPA;S:MyNetwork;P:MyPassword;;" -o wifi.png

# Contact vCard
qrgen "BEGIN:VCARD\nVERSION:3.0\nN:Doe;John\nEND:VCARD" -o contact.png

# Plain text
qrgen "Hello, World!" -o hello.svg
```

### Batch generation with Python

```python
from qr_code_generator import create_qr_code

urls = [
    ("https://example.com", "example.svg"),
    ("https://google.com", "google.svg"),
    ("https://github.com", "github.svg"),
]

for url, filename in urls:
    create_qr_code(url, filename, fg_color="#333333")
    print(f"Generated {filename}")
```

## Development

```bash
# Clone and install with dev dependencies
git clone https://github.com/nabilragab/qrgen.git
cd qrgen
pip install -e ".[dev]"

# Run linting
ruff check src/ tests/

# Run tests
pytest -v

# Build distribution
python -m build
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.