diff options
Diffstat (limited to 'server/src/ui')
| -rw-r--r-- | server/src/ui/assets.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/server/src/ui/assets.rs b/server/src/ui/assets.rs index c956672..91bb5e2 100644 --- a/server/src/ui/assets.rs +++ b/server/src/ui/assets.rs @@ -8,6 +8,7 @@ use crate::{request_info::RequestInfo, responders::cache::CacheControlImage}; use anyhow::Context; use rocket::{get, http::ContentType}; use std::path::PathBuf; +use tokio::task::spawn_blocking; pub const AVIF_QUALITY: u32 = 70; pub const AVIF_SPEED: u8 = 5; @@ -23,9 +24,12 @@ pub async fn r_image( // fit the resolution into a finite set so the maximum cache is finite too. let width = 2usize.pow(size.clamp(128, 2048).ilog2()); - let encoded = + let encoded = spawn_blocking(move || { jellytranscoder::image::transcode(&ri.state.cache, &path, AVIF_QUALITY, AVIF_SPEED, width) - .context("transcoding asset")?; + .context("transcoding asset") + }) + .await + .unwrap()?; Ok((ContentType::AVIF, CacheControlImage(encoded))) } |