Image transformation
Some checks failed
CI / Typos (push) Successful in 20s
CI / Build and test (push) Failing after 2m41s
CI / Clippy (push) Successful in 3m23s
CI / Build and test (all features) (push) Failing after 10m11s
Docker / build-and-push (push) Failing after 1m1s

This commit is contained in:
2026-03-26 11:52:00 -07:00
parent 599c38ac26
commit ec7326a55e
13 changed files with 543 additions and 20 deletions

View File

@@ -31,6 +31,9 @@ pub use group::*;
mod text;
pub use text::*;
mod image;
pub use image::*;
use crate::{
extract::{
misc::MapExtractor,
@@ -41,6 +44,7 @@ use crate::{
pub struct ItemExtractor {
inner: MapExtractor,
image: Arc<ImageExtractor>,
}
impl ItemExtractor {
@@ -91,7 +95,10 @@ impl ItemExtractor {
]),
};
Self { inner }
Self {
inner,
image: Arc::new(ImageExtractor::new(item)),
}
}
}
@@ -103,22 +110,16 @@ impl ObjectExtractor for ItemExtractor {
name: &pile_config::Label,
args: Option<&str>,
) -> Result<Option<PileValue>, std::io::Error> {
self.inner.field(state, name, args).await
if self.image.fields().await?.contains(name) {
self.image.field(state, name, args).await
} else {
self.inner.field(state, name, args).await
}
}
#[expect(clippy::unwrap_used)]
async fn fields(&self) -> Result<Vec<Label>, std::io::Error> {
return Ok(vec![
Label::new("flac").unwrap(),
Label::new("id3").unwrap(),
Label::new("fs").unwrap(),
Label::new("epub").unwrap(),
Label::new("exif").unwrap(),
Label::new("pdf").unwrap(),
Label::new("json").unwrap(),
Label::new("toml").unwrap(),
Label::new("text").unwrap(),
Label::new("groups").unwrap(),
]);
let mut fields = self.inner.fields().await?;
fields.extend(self.image.fields().await?);
Ok(fields)
}
}