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, 7 insertions, 11 deletions
diff --git a/transcoder/src/image.rs b/transcoder/src/image.rs
index 5df21a9..20f7e0c 100644
--- a/transcoder/src/image.rs
+++ b/transcoder/src/image.rs
@@ -6,37 +6,33 @@
use crate::LOCAL_IMAGE_TRANSCODING_TASKS;
use anyhow::Context;
use image::imageops::FilterType;
-use jellybase::{cache::async_cache_file, AssetLocationExt};
-use jellycommon::AssetLocation;
+use jellybase::cache::{async_cache_file, CachePath};
use log::{debug, info};
use rgb::FromSlice;
use std::{
fs::File,
io::{BufReader, Read, Seek, SeekFrom},
+ path::PathBuf,
};
use tokio::io::AsyncWriteExt;
pub async fn transcode(
- asset: AssetLocation,
+ path: PathBuf,
quality: f32,
speed: u8,
width: usize,
-) -> anyhow::Result<AssetLocation> {
- let original_path = asset.path();
- let asset = asset.clone();
+) -> anyhow::Result<CachePath> {
Ok(async_cache_file(
&[
"image-tc",
- original_path.as_os_str().to_str().unwrap(),
+ path.clone().as_os_str().to_str().unwrap(),
&format!("{width} {quality} {speed}"),
],
move |mut output| async move {
let _permit = LOCAL_IMAGE_TRANSCODING_TASKS.acquire().await?;
- info!("encoding {asset:?} (speed={speed}, quality={quality}, width={width})");
+ info!("encoding {path:?} (speed={speed}, quality={quality}, width={width})");
let encoded = tokio::task::spawn_blocking(move || {
- let original_path = asset.path();
- let mut file =
- BufReader::new(File::open(&original_path).context("opening source")?);
+ let mut file = BufReader::new(File::open(&path).context("opening source")?);
// TODO: use better image library that supports AVIF
let is_avif = {