qrcode-scan

v1.0.0

QR code scanning and generation. Invoke when user needs to scan/decode QR codes from images, generate QR codes (text, URL, WiFi), or mentions QR code related...

1· 202·0 current·0 all-time
by末心@moxin1044

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for moxin1044/qrcode-scan.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "qrcode-scan" (moxin1044/qrcode-scan) from ClawHub.
Skill page: https://clawhub.ai/moxin1044/qrcode-scan
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install qrcode-scan

ClawHub CLI

Package manager switcher

npx clawhub@latest install qrcode-scan
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description, SKILL.md, and scripts/main.py are consistent: the skill depends on qrcode, Pillow, and pyzbar and uses urllib to fetch remote images. All requested functionality (file/URL/base64 input, QR generation including WiFi payloads) is supported by the code and justified by the description.
Instruction Scope
SKILL.md limits actions to scanning/generating QR images and shows CLI/Python API usage. It explicitly allows reading local files, base64 blobs, and fetching images from URLs. These are necessary for the feature, but fetching arbitrary URLs introduces an expected network risk (the skill will perform HTTP GETs to any provided URL) and scanning arbitrary local file paths means the skill will read files the user points it at. The instructions do not attempt to read unrelated environment variables or system configs.
Install Mechanism
There is no automated install spec in registry metadata; SKILL.md recommends 'pip install qrcode pillow pyzbar'. This is a normal, traceable install path. Note: pyzbar may require system libraries (zbar) or platform-specific prerequisites (e.g., Visual C++ on Windows) documented in pyzbar's README.
Credentials
The skill requires no environment variables, credentials, or config paths. No secrets are requested or accessed by the code.
Persistence & Privilege
The skill is not marked always:true and does not modify other skills or system-wide settings. It has no special persistence or elevated privileges.
Assessment
This skill appears internally consistent for QR scanning and generation. Before installing or running it: (1) review and run the code in a controlled environment (virtualenv) and inspect dependencies from PyPI; (2) be cautious when providing URLs — the skill will fetch any URL you pass (risk of contacting internal services/SSRF if run in a networked environment); (3) avoid scanning sensitive local images unless you trust the runtime environment, since the tool reads files you point at; (4) note pyzbar may need system libraries (install instructions are in its docs); (5) if you don't want the agent to autonomously fetch URLs, consider restricting autonomous invocation or validating inputs prior to use.

Like a lobster shell, security has layers — review code before you run it.

latestvk9798914zdx93ynzw65fcn89hd83amjr
202downloads
1stars
1versions
Updated 1mo ago
v1.0.0
MIT-0

QR Code Scan & Generate

基于 qrcodepyzbar 的二维码扫描和生成工具。

When to Use This Skill

当用户有以下请求时,应该激活此技能:

  • 扫描/解码二维码

    • "扫描这个二维码图片"
    • "解码二维码"
    • "读取二维码内容"
    • "这个二维码是什么"
  • 生成二维码

    • "生成一个二维码"
    • "创建二维码"
    • "把这段文字转成二维码"
    • "生成网址二维码"
  • WiFi 二维码

    • "生成 WiFi 二维码"
    • "创建 WiFi 分享码"
    • "解析 WiFi 二维码"

依赖安装

pip install qrcode pillow pyzbar

注意:Windows 用户可能需要安装 Visual C++ Redistributable,详见 pyzbar 文档

支持的输入格式

扫描二维码输入

  • 文件路径:本地图片文件路径
  • URL:网络图片地址
  • Base64:Base64 编码的图片数据

生成二维码输出

  • PNG 图片文件:保存到指定路径
  • Base64 字符串:返回 Base64 编码的图片

命令行使用

(注意:如果想要更快速和节省Token,你应该优先使用命令行的方式!)

扫描二维码

python scripts/main.py scan <input> [--format json]

参数:

  • input:图片路径、URL 或 base64 数据
  • --format json:以 JSON 格式输出结果

生成二维码

python scripts/main.py generate <content> --output <path> [--type text|url|wifi]

参数:

  • content:要编码的内容
  • --output:输出文件路径(可选,不指定则输出 base64)
  • --type:二维码类型(text/url/wifi,默认 text)

生成 WiFi 二维码

python scripts/main.py wifi --ssid <SSID> --password <PASSWORD> --security WPA --output <path>

参数:

  • --ssid:WiFi 名称
  • --password:WiFi 密码
  • --security:加密类型(WPA/WEP/NONE,默认 WPA)
  • --output:输出文件路径(可选)

Python API 使用

快速开始

from scripts.main import scan_qrcode, generate_qrcode, generate_wifi_qrcode

# 扫描二维码
result = scan_qrcode("qrcode.png")
print(result)  # 解码内容

# 生成文字二维码
generate_qrcode("Hello World", output_path="output.png")

# 生成 URL 二维码
generate_qrcode("https://example.com", qr_type="url", output_path="url_qr.png")

# 生成 WiFi 二维码
generate_wifi_qrcode("MyWiFi", "password123", security="WPA", output_path="wifi_qr.png")

从 Base64 扫描

from scripts.main import scan_qrcode

# base64 字符串(支持带或不带 data:image 前缀)
result = scan_qrcode("data:image/png;base64,iVBORw0KGgo...")
# 或纯 base64
result = scan_qrcode("iVBORw0KGgo...", input_type="base64")

从 URL 扫描

from scripts.main import scan_qrcode

result = scan_qrcode("https://example.com/qrcode.png")

解析 WiFi 二维码

from scripts.main import scan_qrcode, parse_wifi_qrcode

result = scan_qrcode("wifi_qr.png")
wifi_info = parse_wifi_qrcode(result)
print(wifi_info)
# {'ssid': 'MyWiFi', 'password': 'password123', 'security': 'WPA'}

API Reference

scan_qrcode(input_data, input_type=None, format_json=False)

扫描并解码二维码图片。

参数:

参数类型必需说明
input_datastr图片路径、URL 或 base64 数据
input_typestr输入类型:file/url/base64,自动检测
format_jsonbool是否返回 JSON 格式结果

返回值:

  • strdict:解码内容,多个二维码时返回列表

异常:

  • FileNotFoundError:文件不存在
  • ValueError:无法解码二维码
  • ImportError:缺少依赖库

generate_qrcode(content, output_path=None, qr_type='text', size=10, border=4)

生成二维码图片。

参数:

参数类型必需说明
contentstr要编码的内容
output_pathstr输出文件路径,不指定则返回 base64
qr_typestr二维码类型:text/url/wifi
sizeint二维码尺寸(每个模块的像素数)
borderint边框宽度(模块数)

返回值:

  • str:base64 编码的图片(未指定 output_path 时)
  • None:保存到文件(指定 output_path 时)

generate_wifi_qrcode(ssid, password, security='WPA', output_path=None, hidden=False)

生成 WiFi 配置二维码。

参数:

参数类型必需说明
ssidstrWiFi 名称
passwordstrWiFi 密码
securitystr加密类型:WPA/WEP/NONE
output_pathstr输出文件路径
hiddenbool是否隐藏网络

返回值:

  • str:base64 编码的图片或 None

parse_wifi_qrcode(content)

解析 WiFi 二维码内容。

参数:

参数类型必需说明
contentstr二维码解码内容

返回值:

  • dict:包含 ssidpasswordsecurity 的字典
  • None:如果不是有效的 WiFi 二维码

最佳实践

  1. 扫描二维码

    • 确保图片清晰,分辨率足够
    • 支持常见格式:PNG、JPEG、BMP、GIF
    • 图片中可以有多个二维码,会全部返回
  2. 生成二维码

    • 内容越长,二维码越复杂
    • 建议使用 size=10 以上保证可扫描性
    • URL 类型会自动验证格式
  3. WiFi 二维码

    • 使用 WPA 加密最常见
    • 密码可能包含特殊字符,会自动处理
    • 扫描后手机可直接连接 WiFi

完整示例

from scripts.main import scan_qrcode, generate_qrcode, generate_wifi_qrcode, parse_wifi_qrcode

# 生成并扫描 URL 二维码
generate_qrcode("https://github.com", output_path="github_qr.png")
result = scan_qrcode("github_qr.png")
print(f"扫描结果: {result}")

# 生成 WiFi 二维码
generate_wifi_qrcode(
    ssid="MyHomeWiFi",
    password="MySecurePassword123",
    security="WPA",
    output_path="wifi_qr.png"
)

# 解析 WiFi 二维码
wifi_content = scan_qrcode("wifi_qr.png")
wifi_info = parse_wifi_qrcode(wifi_content)
print(f"WiFi 信息: SSID={wifi_info['ssid']}, 密码={wifi_info['password']}")

# 从 base64 生成并获取 base64 输出
base64_qr = generate_qrcode("Hello World")
print(f"Base64 QR: {base64_qr[:50]}...")

# 扫描网络图片
result = scan_qrcode("https://example.com/qrcode.png")

Comments

Loading comments...