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.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/transcoder/src/image.rs b/transcoder/src/image.rs
index 28b253a..c6e1367 100644
--- a/transcoder/src/image.rs
+++ b/transcoder/src/image.rs
@@ -12,25 +12,23 @@ use rgb::FromSlice;
use std::{
fs::File,
io::{BufReader, Read, Seek, SeekFrom},
- path::PathBuf,
+ path::Path,
};
use tokio::io::AsyncWriteExt;
pub async fn transcode(
- path: PathBuf,
+ path: &Path,
quality: f32,
speed: u8,
width: usize,
) -> anyhow::Result<CachePath> {
async_cache_file(
- &[
- "image-tc",
- path.clone().as_os_str().to_str().unwrap(),
- &format!("{width} {quality} {speed}"),
- ],
- move |mut output| async move {
+ "image-tc",
+ (path, width, quality as i32, speed),
+ |mut output| async move {
let _permit = LOCAL_IMAGE_TRANSCODING_TASKS.acquire().await?;
info!("encoding {path:?} (speed={speed}, quality={quality}, width={width})");
+ let path = path.to_owned();
let encoded = tokio::task::spawn_blocking(move || {
let mut file = BufReader::new(File::open(&path).context("opening source")?);