aboutsummaryrefslogtreecommitdiff
path: root/transcoder/src/image.rs
diff options
context:
space:
mode:
Diffstat (limited to 'transcoder/src/image.rs')
-rw-r--r--transcoder/src/image.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/transcoder/src/image.rs b/transcoder/src/image.rs
index 14b3e53..eaf8b86 100644
--- a/transcoder/src/image.rs
+++ b/transcoder/src/image.rs
@@ -3,21 +3,29 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
-use anyhow::{anyhow, Context, Result};
+use anyhow::{Context, Result, anyhow};
use image::imageops::FilterType;
-use jellycache::{cache, cache_read, HashKey};
+use jellycache::{Cache, HashKey};
use log::{debug, info};
use rgb::FromSlice;
use std::io::Cursor;
-pub fn transcode(key: &str, quality: u32, speed: u8, width: usize) -> Result<Vec<u8>> {
- cache(
+pub fn transcode(
+ cache: &Cache,
+ key: &str,
+ quality: u32,
+ speed: u8,
+ width: usize,
+) -> Result<Vec<u8>> {
+ cache.cache(
&format!(
"transcode/image/{}-W{width}-Q{quality}-S{speed}",
HashKey(key)
),
move || {
- let input = cache_read(key)?.ok_or(anyhow!("transcode cache key missing"))?;
+ let input = cache
+ .read(key)?
+ .ok_or(anyhow!("transcode cache key missing"))?;
info!("encoding image (speed={speed}, quality={quality}, width={width})");
// TODO: use better image library that supports AVIF