QR Code Generator
Generate customizable QR codes for URLs, text, WiFi credentials, contact cards, and more. Supports batch generation, custom styling, logo embedding, and multiple export formats.
⚠️ Prerequisite: Install OpenClawCLI (Windows, MacOS)
Installation:
CODEBLOCK0
Never use --break-system-packages as it can damage your system's Python installation.
Quick Reference
| Task | Command |
|---|
| Basic URL QR code | INLINECODE1 |
| Text QR code |
python scripts/qr.py --type text "Hello World" |
| WiFi QR code |
python scripts/qr.py --type wifi --ssid "MyNetwork" --password "secret" |
| vCard contact |
python scripts/qr.py --type vcard --name "John Doe" --phone "+1234567890" |
| Custom colors |
python scripts/qr.py "URL" --fg-color blue --bg-color white |
| With logo |
python scripts/qr.py "URL" --logo logo.png |
| SVG format |
python scripts/qr.py "URL" --format svg |
| Batch generation |
python scripts/qr.py --batch urls.txt --output-dir qrcodes/ |
Core Features
1. Multiple Data Types
Generate QR codes for various data types with automatic formatting.
Supported Types:
- - URL - Websites and web links
- Text - Plain text messages
- WiFi - WiFi network credentials
- vCard - Contact information (VCF format)
- Email - Email addresses with optional subject/body
- Phone - Phone numbers (tel: links)
- SMS - SMS messages with recipient and text
- Geo - Geographic coordinates
- Event - Calendar events (iCal format)
- Custom - Any custom data
2. Customization Options
Personalize QR code appearance:
- - Foreground and background colors
- Custom error correction levels
- Border size adjustment
- Module size control
- Logo/image embedding
3. Multiple Export Formats
Export in various formats for different use cases:
- - PNG - Raster images (default)
- SVG - Vector graphics (scalable)
- PDF - Print-ready documents
- EPS - Vector format for design tools
- Terminal - ASCII art for terminal display
4. Batch Processing
Generate multiple QR codes from:
- - Text files (one entry per line)
- CSV files (with metadata)
- JSON files (with configuration)
Basic Usage
URL QR Codes
Generate QR codes for websites and links.
CODEBLOCK1
Output:
CODEBLOCK2
Text QR Codes
Encode plain text messages.
CODEBLOCK3
WiFi QR Codes
Create scannable WiFi credentials.
CODEBLOCK4
Security types: WPA, WEP, INLINECODE11
Output QR contains:
CODEBLOCK5
Contact Cards (vCard)
Generate vCard QR codes for easy contact sharing.
CODEBLOCK6
Generated vCard format:
CODEBLOCK7
Email QR Codes
Create mailto: links with optional subject and body.
CODEBLOCK8
Output QR contains:
CODEBLOCK9
Phone Number QR Codes
Generate clickable phone links.
CODEBLOCK10
Output QR contains:
CODEBLOCK11
SMS QR Codes
Create pre-filled SMS messages.
CODEBLOCK12
Output QR contains:
CODEBLOCK13
Geographic Location QR Codes
Encode GPS coordinates.
CODEBLOCK14
Output QR contains:
CODEBLOCK15
Calendar Event QR Codes
Generate iCalendar event QR codes.
CODEBLOCK16
Customization Options
Colors
Customize foreground and background colors.
CODEBLOCK17
Common color names: black, white, red, blue, green, yellow, orange, purple, pink, brown, gray
Error Correction
Set error correction level (higher = more damage resistance).
CODEBLOCK18
Levels:
- - L - Low (~7% recovery) - Use for digital display
- M - Medium (~15% recovery) - Default, good balance
- Q - Quartile (~25% recovery) - Use when adding logos
- H - High (~30% recovery) - Best for print, damaged surfaces
CODEBLOCK19
Size and Border
Control QR code size and border width.
CODEBLOCK20
Defaults:
- - Box size: 10 pixels
- Border: 4 modules (recommended minimum)
Logo Embedding
Add logos or images to QR codes.
CODEBLOCK21
Logo tips:
- - Use square or circular logos
- Keep logo size ≤ 30% of QR code
- Use high error correction (Q or H)
- Test scanning after adding logo
Export Formats
PNG (Default)
Raster image format, good for digital use.
CODEBLOCK22
Best for: Web, digital displays, simple sharing
SVG (Vector)
Scalable vector graphics, perfect for any size.
CODEBLOCK23
Best for: Print, design work, scaling to any size
PDF
Print-ready PDF documents.
CODEBLOCK24
Best for: Printing, documents, archival
EPS
Encapsulated PostScript for professional design tools.
CODEBLOCK25
Best for: Professional design software (Adobe Illustrator, etc.)
Terminal
Display QR code as ASCII art in terminal.
CODEBLOCK26
Output:
CODEBLOCK27
Best for: Quick terminal display, debugging
Batch Generation
From Text File
Generate QR codes from a list of URLs or text.
CODEBLOCK28
Output:
CODEBLOCK29
From CSV File
Generate with metadata (filenames, options).
CODEBLOCK30
From JSON File
Generate with full customization per QR code.
CODEBLOCK31
Common Workflows
Event Check-In System
Generate QR codes for event tickets.
CODEBLOCK32
Restaurant Menu
Create QR code for digital menu.
CODEBLOCK33
WiFi Guest Access
Generate WiFi QR code for guests.
CODEBLOCK34
Contact Card Distribution
Create scannable business cards.
CODEBLOCK35
Product Packaging
QR codes for product information.
CODEBLOCK36
Social Media Links
QR codes for social profiles.
CODEBLOCK37
Payment Links
QR codes for payment services.
CODEBLOCK38
Best Practices
Size and Scanning
- 1. Minimum size: 2cm × 2cm for reliable scanning
- Viewing distance: QR size should be 10% of scanning distance
- Border: Keep at least 4 modules border (quiet zone)
- Testing: Always test scan before printing
Error Correction
- 1. Digital display: Use L or M
- Print without logo: Use M
- Print with logo: Use H
- Outdoor/damaged: Use H
Colors
- 1. High contrast: Dark foreground, light background
- Avoid: Light colors on light, dark on dark
- Print: Use pure black/white for best results
- Branding: Test custom colors before mass production
Logo Integration
- 1. Size: Keep logo ≤ 25-30% of QR code
- Error correction: Use Q or H level
- Position: Center placement works best
- Testing: Verify scanning with logo
File Formats
- 1. Digital: PNG for web, screens
- Print: PDF or SVG for scalability
- Design: SVG or EPS for editing
- Archive: Keep source data and SVG version
Troubleshooting
Installation Issues
"Missing required dependency"
CODEBLOCK39
"PIL/Pillow not found"
CODEBLOCK40
Generation Issues
"QR code too complex"
- - Reduce data size
- Use higher version (auto-adjusts)
- Split into multiple QR codes
"Cannot scan QR code"
- - Increase error correction
- Ensure sufficient contrast
- Check minimum size
- Remove or reduce logo size
- Test in good lighting
"Logo obscures data"
- - Reduce logo size (--logo-size)
- Increase error correction to H
- Use simpler logo design
File Issues
"Cannot save file"
- - Check output directory exists
- Verify write permissions
- Check disk space
"Invalid color format"
- - Use named colors: red, blue, green
- Use hex: #RRGGBB
- Use rgb: rgb(R,G,B)
Command Reference
CODEBLOCK41
Examples by Use Case
Quick QR Codes
CODEBLOCK42
Professional QR Codes
CODEBLOCK43
Functional QR Codes
CODEBLOCK44
Bulk Generation
CODEBLOCK45
Support
For issues or questions:
- 1. Check this documentation
- Run INLINECODE12
- Verify dependencies are installed
- Test with simple QR code first
Resources:
- - OpenClawCLI: https://clawhub.ai/
- qrcode library: https://pypi.org/project/qrcode/
- segno library: https://pypi.org/project/segno/
- QR code specification: ISO/IEC 18004
QR Code Generator
为URL、文本、WiFi凭证、联系人名片等生成可自定义的二维码。支持批量生成、自定义样式、嵌入Logo以及多种导出格式。
⚠️ 前置条件: 安装 OpenClawCLI(支持Windows、MacOS)
安装方法:
bash
标准安装
pip install qrcode[pil] segno
如果遇到权限错误,请使用虚拟环境
python -m venv venv
source venv/bin/activate # Windows系统: venv\Scripts\activate
pip install qrcode[pil] segno
切勿使用 --break-system-packages,否则可能损坏系统的Python安装。
快速参考
| 任务 | 命令 |
|---|
| 基本URL二维码 | python scripts/qr.py https://example.com |
| 文本二维码 |
python scripts/qr.py --type text Hello World |
| WiFi二维码 | python scripts/qr.py --type wifi --ssid MyNetwork --password secret |
| vCard联系人 | python scripts/qr.py --type vcard --name John Doe --phone +1234567890 |
| 自定义颜色 | python scripts/qr.py URL --fg-color blue --bg-color white |
| 带Logo | python scripts/qr.py URL --logo logo.png |
| SVG格式 | python scripts/qr.py URL --format svg |
| 批量生成 | python scripts/qr.py --batch urls.txt --output-dir qrcodes/ |
核心功能
1. 多种数据类型
为各种数据类型生成二维码,并自动格式化。
支持的类型:
- - URL - 网站和网页链接
- 文本 - 纯文本消息
- WiFi - WiFi网络凭证
- vCard - 联系人信息(VCF格式)
- 电子邮件 - 电子邮件地址(可附带主题/正文)
- 电话 - 电话号码(tel:链接)
- 短信 - 带收件人和文本的短信消息
- 地理位置 - 地理坐标
- 事件 - 日历事件(iCal格式)
- 自定义 - 任意自定义数据
2. 自定义选项
个性化二维码外观:
- - 前景色和背景色
- 自定义纠错级别
- 边框大小调整
- 模块大小控制
- Logo/图片嵌入
3. 多种导出格式
根据不同使用场景导出多种格式:
- - PNG - 光栅图像(默认)
- SVG - 矢量图形(可缩放)
- PDF - 打印就绪文档
- EPS - 设计工具矢量格式
- 终端 - 终端显示的ASCII艺术
4. 批量处理
从以下来源批量生成二维码:
- - 文本文件(每行一个条目)
- CSV文件(带元数据)
- JSON文件(带配置)
基本用法
URL二维码
为网站和链接生成二维码。
bash
简单URL
python scripts/qr.py https://example.com
自定义文件名
python scripts/qr.py https://github.com --output github_qr.png
高纠错级别(用于打印)
python scripts/qr.py https://mysite.com --error-correction H --output site_qr.png
输出结果:
QR code generated: qrcode.png
Size: 290x290 pixels
Error correction: M (Medium)
Data: https://example.com
文本二维码
编码纯文本消息。
bash
简单文本
python scripts/qr.py --type text Hello, World!
多行文本
python scripts/qr.py --type text Line 1\nLine 2\nLine 3 --output message.png
大段文本(自动调整大小)
python scripts/qr.py --type text $(cat message.txt) --output text_qr.png
WiFi二维码
创建可扫描的WiFi凭证。
bash
WPA/WPA2网络
python scripts/qr.py --type wifi --ssid MyNetwork --password SecurePassword123
WPA2网络(显式指定)
python scripts/qr.py --type wifi --ssid HomeWiFi --password pass123 --security WPA
隐藏网络
python scripts/qr.py --type wifi --ssid SecretNet --password secret --hidden
开放网络(无密码)
python scripts/qr.py --type wifi --ssid GuestNetwork --security nopass
安全类型: WPA、WEP、nopass
输出二维码包含:
WIFI:T:WPA;S:MyNetwork;P:SecurePassword123;H:false;;
联系人名片(vCard)
生成vCard二维码,方便联系人分享。
bash
基本联系人
python scripts/qr.py --type vcard --name John Doe --phone +1234567890
完整联系人信息
python scripts/qr.py --type vcard \
--name Jane Smith \
--phone +1234567890 \
--email jane@example.com \
--organization Tech Corp \
--title Senior Developer \
--url https://janesmith.com \
--address 123 Main St, City, State, 12345 \
--output jane_contact.png
多个电话号码
python scripts/qr.py --type vcard \
--name Bob Johnson \
--phone +1234567890 \
--phone-home +0987654321 \
--email bob@email.com
生成的vCard格式:
BEGIN:VCARD
VERSION:3.0
FN:John Doe
TEL:+1234567890
END:VCARD
电子邮件二维码
创建mailto:链接,可附带主题和正文。
bash
简单电子邮件
python scripts/qr.py --type email --email contact@example.com
带主题
python scripts/qr.py --type email --email support@company.com --subject Support Request
带主题和正文
python scripts/qr.py --type email \
--email info@example.com \
--subject Inquiry \
--body I would like more information about...
输出二维码包含:
mailto:contact@example.com?subject=Support%20Request&body=Message%20text
电话号码二维码
生成可点击的电话链接。
bash
简单电话号码
python scripts/qr.py --type phone --phone +1234567890
国际格式
python scripts/qr.py --type phone --phone +44 20 7946 0958
输出二维码包含:
tel:+1234567890
短信二维码
创建预填短信消息。
bash
仅含收件人的短信
python scripts/qr.py --type sms --phone +1234567890
带消息的短信
python scripts/qr.py --type sms --phone +1234567890 --message Hello from QR code!
输出二维码包含:
sms:+1234567890?body=Hello%20from%20QR%20code!
地理位置二维码
编码GPS坐标。
bash
仅坐标
python scripts/qr.py --type geo --latitude 37.7749 --longitude -122.4194
带海拔
python scripts/qr.py --type geo --latitude 40.7128 --longitude -74.0060 --altitude 10
命名位置
python scripts/qr.py --type geo --latitude 51.5074 --longitude -0.1278 --location-name London
输出二维码包含:
geo:37.7749,-122.4194
日历事件二维码
生成iCalendar事件二维码。
bash
基本事件
python scripts/qr.py --type event \
--event-title Team Meeting \
--event-start 2024-03-15T14:00:00 \
--event-end 2024-03-15T15:00:00
完整事件详情
python scripts/qr.py --type event \
--event-title Conference 2024 \
--event-start 2024-06-01T09:00:00 \
--event-end 2024-06-01T17:00:00 \
--event-location Convention Center, NYC \
--event-description Annual tech conference \
--output conference_qr.png
自定义选项
颜色
自定义前景色和背景色。
bash
命名颜色
python scripts/qr.py https://example.com --fg-color blue --bg-color