数据分析

Qr Generator

试用

QR code generator. Use when user needs to create QR codes for text, URLs, WiFi, vCards, or any data. Supports custom colors, sizes, logos, and formats (PNG/S...

它能做什么

Professional QR code generator with custom styling and multiple data formats.

技能文档

QR Generator

Professional QR code generator with custom styling and multiple data formats.

Features

  • 📱 Multiple Formats: Text, URL, WiFi, vCard, Email, SMS
  • 🎨 Custom Styling: Colors, size, error correction
  • 🖼️ Logo Embedding: Add logo to center of QR code
  • 📐 Flexible Output: PNG, SVG, PDF formats
  • 🌍 Multi-Language: Supports all Unicode text
  • ✅ Cross-Platform: Windows, macOS, Linux

Supported QR Types

TypeUse CaseExample
TextSimple text"Hello World"
URLWebsite links"https://example.com"
WiFiAuto-connectSSID + Password
vCardContact infoName, Phone, Email
EmailSend emailmailto:user@example.com
SMSSend SMSsms:+1234567890
PhoneCall numbertel:+1234567890
GeoLocationgeo:lat,lng

Trigger Conditions

  • "生成二维码" / "Generate QR code"
  • "创建二维码" / "Create QR code"
  • "WiFi二维码" / "WiFi QR code"
  • "名片二维码" / "vCard QR code"
  • "qr-generator"

Step 1: Understand Requirements

请提供以下信息:

内容类型:(文本/URL/WiFi/名片/其他)
具体内容:
输出格式:(PNG/SVG)
尺寸要求:(小/中/大/自定义)
颜色要求:(默认/自定义)
是否需要Logo:

Step 2: Generate QR Code

Python Script Template

python3 << 'PYEOF'
import os
import qrcode
from qrcode.image.styledpil import StyledPilImage
from qrcode.image.styles.moduledrawers import (
    SquareModuleDrawer,
    CircleModuleDrawer,
    RoundedModuleDrawer
)
from qrcode.image.styles.colormasks import (
    SolidFillColorMask,
    RadialGradiantColorMask,
    SquareGradiantColorMask
)
from PIL import Image

class QRGenerator:
    def __init__(self):
        self.qr = qrcode.QRCode(
            version=1,
            error_correction=qrcode.constants.ERROR_CORRECT_H,
            box_size=10,
            border=4,
        )
    
    def generate_text(self, text, output_path, **kwargs):
        """Generate QR code for text"""
        return self._generate(text, output_path, **kwargs)
    
    def generate_url(self, url, output_path, **kwargs):
        """Generate QR code for URL"""
        return self._generate(url, output_path, **kwargs)
    
    def generate_wifi(self, ssid, password, security='WPA', output_path=None, **kwargs):
        """Generate QR code for WiFi"""
        wifi_string = f'WIFI:T:{security};S:{ssid};P:{password};;'
        return self._generate(wifi_string, output_path, **kwargs)
    
    def generate_vcard(self, name, phone='', email='', org='', output_path=None, **kwargs):
        """Generate QR code for vCard"""
        vcard = f"""BEGIN:VCARD
VERSION:3.0
N:{name}
FN:{name}
TEL:{phone}
EMAIL:{email}
ORG:{org}
END:VCARD"""
        return self._generate(vcard, output_path, **kwargs)
    
    def generate_email(self, email, subject='', body='', output_path=None, **kwargs):
        """Generate QR code for email"""
        mailto = f'mailto:{email}'
        if subject or body:
            mailto += '?'
            params = []
            if subject:
                params.append(f'subject={subject}')
            if body:
                params.append(f'body={body}')
            mailto += '&'.join(params)
        return self._generate(mailto, output_path, **kwargs)
    
    def generate_phone(self, phone, output_path=None, **kwargs):
        """Generate QR code for phone call"""
        return self._generate(f'tel:{phone}', output_path, **kwargs)
    
    def generate_sms(self, phone, message='', output_path=None, **kwargs):
        """Generate QR code for SMS"""
        sms = f'sms:{phone}'
        if message:
            sms += f'?body={message}'
        return self._generate(sms, output_path, **kwargs)
    
    def _generate(self, data, output_path, 
                  fill_color='black', 
                  back_color='white',
                  size=10,
                  style='square',
                  logo_path=None):
        """Generate QR code with options"""
        
        # Reset QR code
        self.qr.clear()
        self.qr.add_data(data)
        self.qr.make(fit=True)
        
        # Set colors
        if isinstance(fill_color, str):
            fill_color = self._hex_to_rgb(fill_color)
        if isinstance(back_color, str):
            back_color = self._hex_to_rgb(back_color)
        
        # Choose module drawer
        drawers = {
            'square': SquareModuleDrawer(),
            'circle': CircleModuleDrawer(),
            'rounded': RoundedModuleDrawer()
        }
        drawer = drawers.get(style, SquareModuleDrawer())
        
        # Generate image
        img = self.qr.make_image(
            image_factory=StyledPilImage,
            module_drawer=drawer,
            color_mask=SolidFillColorMask(
                back_color=back_color,
                front_color=fill_color
            )
        )
        
        # Convert to PIL Image
        img = img.convert('RGBA')
        
        # Resize if needed
        if size != 10:
            new_size = img.size[0] * size // 10
            img = img.resize((new_size, new_size), Image.LANCZOS)
        
        # Add logo if provided
        if logo_path and os.path.exists(logo_path):
            img = self._add_logo(img, logo_path)
        
        # Save
        img.save(output_path)
        return output_path
    
    def _add_logo(self, qr_img, logo_path, logo_size_ratio=0.2):
        """Add logo to center of QR code"""
        logo = Image.open(logo_path).convert('RGBA')
        
        # Calculate logo size
        qr_width, qr_height = qr_img.size
        logo_size = int(min(qr_width, qr_height) * logo_size_ratio)
        logo = logo.resize((logo_size, logo_size), Image.LANCZOS)
        
        # Calculate position
        logo_pos = ((qr_width - logo_size) // 2, (qr_height - logo_size) // 2)
        
        # Create white background for logo
        logo_bg = Image.new('RGBA', (logo_size + 10, logo_size + 10), (255, 255, 255, 255))
        bg_pos = ((qr_width - logo_size - 10) // 2, (qr_height - logo_size - 10) // 2)
        
        # Paste
        qr_img.paste(logo_bg, bg_pos)
        qr_img.paste(logo, logo_pos, logo)
        
        return qr_img
    
    def _hex_to_rgb(self, hex_color):
        """Convert hex color to RGB tuple"""
        hex_color = hex_color.lstrip('#')
        return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))

# Example usage
generator = QRGenerator()

output_dir = os.environ.get('OPENCLAW_WORKSPACE', os.getcwd())

# Text QR
generator.generate_text(
    'Hello World!',
    os.path.join(output_dir, 'qr_text.png')
)

# URL QR
generator.generate_url(
    'https://github.com',
    os.path.join(output_dir, 'qr_url.png'),
    fill_color='#1a365d'
)

# WiFi QR
generator.generate_wifi(
    ssid='MyWiFi',
    password='password123',
    output_path=os.path.join(output_dir, 'qr_wifi.png'),
    fill_color='#3182ce'
)

# vCard QR
generator.generate_vcard(
    name='John Doe',
    phone='+1234567890',
    email='john@example.com',
    org='Example Corp',
    output_path=os.path.join(output_dir, 'qr_vcard.png')
)

print(f"✅ QR codes generated in: {output_dir}")
PYEOF

QR Code Types (二维码类型)

WiFi QR Code

# Format: WIFI:T:{security};S:{ssid};P:{password};H:{hidden};;

# WPA/WPA2
WIFI:T:WPA;S:MyNetwork;P:MyPassword;;

# WEP
WIFI:T:WEP;S:MyNetwork;P:MyPassword;;

# No password
WIFI:T:nopass;S:MyNetwork;;

vCard QR Code

# Format: vCard 3.0
BEGIN:VCARD
VERSION:3.0
N:Lastname;Firstname
FN:Firstname Lastname
TEL:+1234567890
EMAIL:email@example.com
ORG:Company Name
TITLE:Job Title
URL:https://example.com
ADR:;;Street;City;State;Zip;Country
END:VCARD

Email QR Code

# Format: mailto:{email}?subject={subject}&body={body}
mailto:contact@example.com?subject=Hello&body=Message

Styling Options (样式选项)

Colors

# Solid colors
fill_color='#000000'  # Black
fill_color='#1a365d'  # Dark blue
fill_color='#3182ce'  # Blue

# Gradients (advanced)
color_mask=RadialGradiantColorMask(
    back_color=(255, 255, 255),
    center_color=(0, 0, 0),
    edge_color=(100, 100, 100)
)

Module Styles

# Square (default)
style='square'

# Circle
style='circle'

# Rounded
style='rounded'

Sizes

# Small (for mobile)
size=5

# Medium (default)
size=10

# Large (for print)
size=20

# Custom pixels
box_size=15  # Each module = 15 pixels

Security Notes

  • ✅ No network calls or external endpoints
  • ✅ No credentials or API keys required
  • ✅ Local file processing only
  • ✅ Open source dependencies (qrcode, pillow)
  • ✅ No data uploaded to external servers

Notes

  • QR codes support up to 4,296 alphanumeric characters
  • Error correction levels: L(7%), M(15%), Q(25%), H(30%)
  • Higher error correction = more reliable but larger size
  • Logo embedding reduces error correction capacity

相关技能

把自然语言描述转为结构化 JSON,并由 mcp-diagram-generator MCP 服务生成 Draw.io、Mermaid 或 Excalidraw 图表文件。

作者 nssa.io1.0k 次安装47 星标

以 AI 机器人身份加入视频会议,提供语音、虚拟形象与屏幕共享四种模式。

作者 johnpatternai22 次安装8 星标

诊断生产力系统反复失效的根因,给出最小干预——容量测算、瓶颈定位、可靠的本地记录。

作者 Iván855 次安装69 星标

在本地磁盘以分类纯 Markdown 文件保存需要长期留存的事实,与智能体内置记忆并存。

作者 Iván559 次安装18 星标

从 AdMapix API 拉取广告创意、应用、榜单和收入预估等数据,原样返回结构化 JSON。

作者 fly0pants4.3k 次安装296 星标

tobewin 的更多技能

浏览全部技能

用一份 JSON 描述就能生成标准可编辑的 PPTX,自带 11 种版式与 5 套配色。

作者 ToBeWin329 次安装3 星标

把 Word、PDF、Excel、PowerPoint、HTML、Markdown 与 TXT 文档翻译成另一种语言,同时保留原始排版。

作者 tobewin36 次安装1 星标

Professional Excel spreadsheet generator. Use when user needs to create data tables, reports, charts, financial models, or any structured data in Excel forma...

作者 ToBeWin82 次安装3 星标

中国新闻资讯聚合工具。Use when user wants to get latest news from Chinese sources. Supports multiple news sites (Sina, Sohu, NetEase, Tencent) via browser automation an...

作者 ToBeWin57 次安装3 星标

Data analysis tool for Excel, CSV, Word, PDF, TXT, Markdown files. Use when user needs to analyze, summarize, or compare data from multiple files. Supports f...

作者 ToBeWin68 次安装1 星标

Marketing plan generator with web research and Word output. Use when user needs to create marketing plans, promotional campaigns, social media strategies. Fe...

作者 ToBeWin31 次安装1 星标