minify the output size
This commit is contained in:
parent
8aac2981d7
commit
7cf00857bb
|
@ -533,6 +533,7 @@ dependencies = [
|
||||||
"image",
|
"image",
|
||||||
"qrcode",
|
"qrcode",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"urlencoding",
|
||||||
"warp",
|
"warp",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1191,6 +1192,12 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "urlencoding"
|
||||||
|
version = "2.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf-8"
|
name = "utf-8"
|
||||||
version = "0.7.6"
|
version = "0.7.6"
|
||||||
|
|
|
@ -9,6 +9,7 @@ edition = "2021"
|
||||||
image = "0.23.0"
|
image = "0.23.0"
|
||||||
qrcode = "0.12.0"
|
qrcode = "0.12.0"
|
||||||
tokio = { version = "1.33.0", features = ["full"] }
|
tokio = { version = "1.33.0", features = ["full"] }
|
||||||
|
urlencoding = "2.1.3"
|
||||||
warp = "0.3.6"
|
warp = "0.3.6"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -1,5 +1,6 @@
|
||||||
use qrcode::QrCode;
|
use qrcode::QrCode;
|
||||||
use image::{Luma, png::PngEncoder};
|
use image::{Luma, png::PngEncoder};
|
||||||
|
use urlencoding::decode;
|
||||||
|
|
||||||
use warp::{Filter, reply::Response};
|
use warp::{Filter, reply::Response};
|
||||||
|
|
||||||
|
@ -14,9 +15,14 @@ async fn main() {
|
||||||
.and(
|
.and(
|
||||||
warp::get()
|
warp::get()
|
||||||
)
|
)
|
||||||
.map(|x| {
|
.map(|x: String| {
|
||||||
let code = QrCode::new(x).unwrap();
|
let text = decode(x.as_str()).unwrap().to_string();
|
||||||
let img = code.render::<Luma<u8>>().build();
|
let code = QrCode::with_error_correction_level(text, qrcode::EcLevel::M).unwrap();
|
||||||
|
let img = code
|
||||||
|
.render::<Luma<u8>>()
|
||||||
|
.quiet_zone(false)
|
||||||
|
.module_dimensions(1, 1)
|
||||||
|
.build();
|
||||||
|
|
||||||
let mut out = Vec::<u8>::new();
|
let mut out = Vec::<u8>::new();
|
||||||
let enc = PngEncoder::new(&mut out);
|
let enc = PngEncoder::new(&mut out);
|
||||||
|
|
Loading…
Reference in New Issue