qrencode linux下二维码生成工具介绍

安装qrencode(附官方手册)

# 官方文档
    https://fukuchi.org/works/qrencode/index.html.en
    https://formulae.brew.sh/formula/qrencode     (内含 api文档)

# rhel7系列(base源中)
    yum install qrencode -y

# debian系列
    apt install qrencode -y

# openwrt系列
    opkg update ; opkg install qrencode

工具参数介绍

    -o filename.png         # 输出到文件(格式为png)
    -s
    -l [L|M|Q|H]            # 指定从L(最低)到H(最高)的纠错级别
    -m 4                    # 指定二维码的边框(即边距)宽带,默认为4,建议指定为1
    -d 72                   # 指定生成二维码图片的dpi,默认是72
    -t [PNG|EPS|SVG|ANSI]   # 指定生成的图像格式,默认为PNG,可选有 PNG、EPS、SVG、ANSI、ANSI256、ASCII、ASCIIi、UTF8、ANSIUTF8  (shell终端建议使用 ANSI、ANSI256、) 

    附:若是你想生成彩色的二维码,可以配置lolcat工具

典型使用案例

# 看看 ANSI ANSI256 ASCII ASCIIi UTF8 ANSIUTF8 这几种类型的二维码在shell终端的展示情况
    for type in ANSI ANSI256 ASCII ASCIIi UTF8 ANSIUTF8;do echo $type ;qrencode -t $type "a";done

# 直接显示在终端(不推荐使用UTF8格式,你用你就知道什么像样儿了)
    echo "你好" | qrencode -t ansi256
    # qrencode -t ansi256 "你好"
    echo "你好" | qrencode -t ansi256 > device_code   # 将生成的二维码直接重定向到文件device_code,便于cat读取

# 推荐使用
    qrencode -m 2 -t ansiutf8 "$str"

# 生成png图片
    qrencode -o qrcode.png "你好"
声明:本文为原创,作者为 辣条①号,转载时请保留本声明及附带文章链接:https://boke.wsfnk.com/archives/1412.html
谢谢你请我吃辣条谢谢你请我吃辣条

如果文章对你有帮助,欢迎点击上方按钮打赏作者

最后编辑于:2025/2/4作者: 辣条①号

目标:网络规划设计师、系统工程师、ceph存储工程师、云计算工程师。 不负遇见,不谈亏欠!

暂无评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

arrow grin ! ? cool roll eek evil razz mrgreen smile oops lol mad twisted wink idea cry shock neutral sad ???

文章目录