feat: Logo 嵌入 — QR 码中央叠加自定义图片

- PNG 渲染:RgbaImage 上使用 imageops::overlay 叠加 logo
- SVG 渲染:base64 编码 logo 嵌入 <image> 标签
- QrCode::to_png_bytes / to_svg 新增 Option<logo_bytes> 参数
- Logo 默认占 QR 区域 25%,建议配合 H 级纠错使用
This commit is contained in:
2026-06-19 21:12:44 +08:00
parent 23ccb37b52
commit 38be82973e
10 changed files with 112 additions and 40 deletions
+2 -2
View File
@@ -69,10 +69,10 @@ async fn generate_qr(Query(params): Query<QrParams>) -> impl IntoResponse {
};
if params.fmt == "svg" {
let svg = qr.to_svg();
let svg = qr.to_svg(None);
([(header::CONTENT_TYPE, "image/svg+xml")], svg).into_response()
} else {
match qr.to_png_bytes(params.size) {
match qr.to_png_bytes(params.size, None) {
Ok(b) => ([(header::CONTENT_TYPE, "image/png")], b).into_response(),
Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
}