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