diff options
-rw-r--r-- | server/src/routes/ui/assets.rs | 4 | ||||
-rw-r--r-- | transcoder/src/image.rs | 2 |
2 files changed, 4 insertions, 2 deletions
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, diff --git a/transcoder/src/image.rs b/transcoder/src/image.rs index d721e7b..29ad423 100644 --- a/transcoder/src/image.rs +++ b/transcoder/src/image.rs @@ -39,7 +39,7 @@ pub fn transcode( image.width() as usize, image.height() as usize, ))?; - info!("writing to cache: {path:?}"); + info!("transcode finished"); File::create(&path)?.write_all(&encoded.avif_file)?; } Ok(path) |