From 85a4beeb54a33e6487839ba5f496e3cf69dc4bf2 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 13 Jul 2023 11:00:57 +0100 Subject: [PATCH] Fix panicking issue. --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index afe8b41..ea21857 100644 --- a/src/main.rs +++ b/src/main.rs @@ -215,10 +215,16 @@ async fn index(req: HttpRequest) -> Result> { let image = image::load_from_memory(&resp_bytes).unwrap(); + let width = image.width() as usize; + let height = image.height() as usize; + + let buf = image.into_rgb8(); + let buf = buf.as_raw().as_rgb(); + let buffer = Img::new( - image.as_rgb8().unwrap().as_raw().as_rgb(), - image.width() as usize, - image.height() as usize, + buf, + width, + height, ); let res = Encoder::new()