Encode Text to QR Image (utils.qr_encode)
Declaration
img = utils.qr_encode(text[, {
size = size,
fill_color = fill_color,
shadow_color = shadow_color,
}])
Parameters
- text
String. Text to encode. - size
Integer. Side length of the QR image. Default: 320. - fill_color
Integer. Fill color. Default: 0xff000000 (black, opaque). - shadow_color
Integer. Shadow color. Default: 0x00000000 (fully transparent).
Returns
- img
Image object. The generated QR image with transparent background (0x00000000).
Examples
- Generate a 320px blue QR with transparent background and save to album
local img = utils.qr_encode("XXTouch is awesome", {
size = 320,
fill_color = 0xff409bff,
shadow_color = 0xff308bef,
})
img:save_to_album()
Note: uses :save_to_album
- If some apps cannot recognize QR with transparent/dark background, replace background to white via
:replace_color
:
local img = utils.qr_encode("XXTouch is awesome", {
size = 320,
fill_color = 0xff000000,
})
img:replace_color(0x00000000, 0xffffffff)
img:save_to_album()
Note: uses :replace_color
, :save_to_album