From 3fb34048a1efc0a24766288d3d2d0b7f30c141c4 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 6 Aug 2023 15:30:58 +0200 Subject: transcode width grid --- server/src/routes/ui/assets.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/src/routes/ui/assets.rs b/server/src/routes/ui/assets.rs index 2d175f9..f2c3f3f 100644 --- a/server/src/routes/ui/assets.rs +++ b/server/src/routes/ui/assets.rs @@ -47,7 +47,9 @@ pub async fn r_item_assets( let asset = asset.unwrap_or(AssetLocation::Assets( PathBuf::from_str("fallback.jpeg").unwrap(), )); - let path = jellytranscoder::image::transcode(asset, 50., 5, width.unwrap_or(2048))?; + // fit the resolution into a finite set so the maximum cache is finite too. + let width = 2usize.pow(width.unwrap_or(2048).clamp(128, 8196).ilog2()); + let path = jellytranscoder::image::transcode(asset, 50., 5, width)?; info!("loading asset from {path:?}"); Ok(( ContentType::AVIF, -- cgit v1.2.3-70-g09d2