aboutsummaryrefslogtreecommitdiffstats
path: root/src/commands/qr.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/commands/qr.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/commands/qr.rs b/src/commands/qr.rs
index 26232ee..c0b8af0 100644
--- a/src/commands/qr.rs
+++ b/src/commands/qr.rs
@@ -61,10 +61,14 @@ pub async fn dekodowanie(
61 .await? 61 .await?
62 .bytes() 62 .bytes()
63 .await?; 63 .await?;
64 let img = image::load_from_memory(&img_data)?; 64 // Decoding is CPU-heavy: keep it off the async runtime.
65 let gray = img.to_luma8(); 65 let img_data = img_data.to_vec();
66 66 let decoded = tokio::task::spawn_blocking(move || {
67 let decoded = decode_qr_simple(&gray); 67 let img = image::load_from_memory(&img_data).ok()?;
68 let gray = img.to_luma8();
69 decode_qr_simple(&gray)
70 })
71 .await?;
68 match decoded { 72 match decoded {
69 Some(text) => { 73 Some(text) => {
70 ctx.say(lang::fmt_qr_decoded(&text)).await?; 74 ctx.say(lang::fmt_qr_decoded(&text)).await?;