Qrencode
qrencode for lua
Install / Use
/learn @vincascm/QrencodeREADME
qrencode: qrencode is a wrapper of libqrencode with libpng for lua.
qrencode is a wrapper of libqrencode with libpng for lua.
Install
qrencode is dependent on libqrencode and libpng, so make sure these are installed before compile it.
CentOS
yum install -y qrencode-devel libpng-devel
make
Example usage
simple usage
qr = require "qrencode"
-- print PNG data stream to stdout.
print(qr.encode("is ok?"))
print(qr:encode("is ok?"))
print(qr("is ok?"))
print(qr {text = "is ok?", level = "M"})
-- or pass a table :
print(qr {
text="is ok?",
level="L",
kanji=false,
size=4,
margin=2,
symversion=0,
dpi=78,
casesensitive=false,
foreground="48AF6D",
background="3FAF6F"
}
)
in nginx lua
local qr = require "qrencode"
local args = ngx.req.get_uri_args()
ngx.header.content_type = 'image/png'
ngx.say(
qr {
text = args.text,
size = args.size or 8,
margin = args.margin or 1,
symversion = 2,
level = 'M',
foreground = args.fg,
background = args.bg
}
)
or nginx config file
server {
server_name qr.corp.com;
location /qr {
content_by_lua_block {
local qr = require "qrencode"
local args = ngx.req.get_uri_args()
ngx.header.content_type = 'image/png'
ngx.say( qr {
text = args.text,
size = args.size or 8,
margin = args.margin or 1,
symversion = 2,
level = 'M',
foreground = args.fg,
background = args.bg
})
}
}
}
and visit http://qr.corp.com/qr?text=works to test it.
when pass a table, "text" is required and other is optional.
Author
vinoca https://www.vinoca.org/
Copyright and license
Code and documentation copyright 2014-2020 vinoca. Code released under the MIT license. Docs released under Creative commons.
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
