hutool.extra.qr_code¶
二维码工具类,基于qrcode
Module Contents¶
Classes¶
二维码工具类,基于qrcode |
API¶
- class hutool.extra.qr_code.QrCodeUtil¶
二维码工具类,基于qrcode
- static generate(content: str, width: int = 300, height: int = 300) PIL.Image.Image¶
生成二维码,返回PIL Image对象
- 参数:
content – 二维码内容
width – 图片宽度(像素)
height – 图片高度(像素)
- 返回:
PIL Image对象
- static generate_as_bytes(content: str, width: int = 300, height: int = 300, fmt: str = 'png') bytes¶
生成二维码并返回字节数组
- 参数:
content – 二维码内容
width – 图片宽度(像素)
height – 图片高度(像素)
fmt – 图片格式,默认为 ‘png’
- 返回:
图片字节数组
- static generate_to_file(content: str, path: str, width: int = 300, height: int = 300) None¶
生成二维码并保存到文件
- 参数:
content – 二维码内容
path – 输出文件路径
width – 图片宽度(像素)
height – 图片高度(像素)
- static generate_as_base64(content: str, width: int = 300, height: int = 300) str¶
生成二维码的Base64编码
- 参数:
content – 二维码内容
width – 图片宽度
height – 图片高度
- 返回:
Base64编码字符串
- static generate_as_svg(content: str, width: int = 300, height: int = 300) str¶
生成SVG格式的二维码
- 参数:
content – 二维码内容
width – SVG宽度
height – SVG高度
- 返回:
SVG格式字符串
- static decode(image) str¶
解码二维码图片
- 参数:
image – PIL Image对象或图片字节数据或文件路径
- 返回:
二维码内容字符串
- static generate_as_ascii_art(content: str, width: int = 0, height: int = 0) str¶
生成 ASCII 艺术二维码。
将二维码转为文本形式的 ASCII art。
- 参数:
content – 二维码内容
width – 图片宽度(像素),0 表示使用默认值
height – 图片高度(像素),0 表示使用默认值
- 返回:
ASCII 艺术字符串
- static to_ascii_art(image) str¶
将 QR 图片转为 ASCII 艺术。
- 参数:
image – PIL Image 对象或图片文件路径
- 返回:
ASCII 艺术字符串