[repo] Format, clippy clean, FORMATS.md, the full crate table in DEPENDENCIES.md

This commit is contained in:
2026-11-16 13:58:06 +01:00
parent 196802863a
commit a06e3f9b73
17 changed files with 2708 additions and 2125 deletions
+11 -5
View File
@@ -238,8 +238,11 @@ pub fn dispatch(state: &mut State, op: &str, a: Value) -> Result<Value, OpError>
}
let a: A = args(a)?;
let engine = state.engine()?;
let files: Vec<(Vec<u8>, Option<String>)> =
a.inputs.iter().map(|i| read_file(&i.path).map(|b| (b, i.password.clone()))).collect::<Result<_, _>>()?;
let files: Vec<(Vec<u8>, Option<String>)> = a
.inputs
.iter()
.map(|i| read_file(&i.path).map(|b| (b, i.password.clone())))
.collect::<Result<_, _>>()?;
let refs: Vec<(&[u8], Option<&str>)> = files.iter().map(|(b, p)| (b.as_slice(), p.as_deref())).collect();
let bytes = pictor_pdf::merge(engine, &refs)?;
write_out(&a.output, &bytes, SaveMode::New)
@@ -309,7 +312,8 @@ pub fn dispatch(state: &mut State, op: &str, a: Value) -> Result<Value, OpError>
let bytes = read_file(&a.path)?;
let img = pictor_raster::decode(&bytes, &Limits::default())?;
let (w, h) = (img.width(), img.height());
let t = pictor_raster::resize(&img, pictor_raster::Fit::LongEdge(a.max.clamp(16, 2048)), &Limits::default())?;
let t =
pictor_raster::resize(&img, pictor_raster::Fit::LongEdge(a.max.clamp(16, 2048)), &Limits::default())?;
Ok(json!({"png": b64(&png(&t)?), "width": w, "height": h}))
}
"image.convert" => {
@@ -347,7 +351,8 @@ pub fn dispatch(state: &mut State, op: &str, a: Value) -> Result<Value, OpError>
if let Some(f) = a.resize {
img = pictor_raster::resize(&img, f, &limits)?;
}
let format = Format::from_name(&a.format).ok_or_else(|| OpError::new("invalid", "Choose an output format."))?;
let format =
Format::from_name(&a.format).ok_or_else(|| OpError::new("invalid", "Choose an output format."))?;
let (bytes, format) = if let Some(target) = a.target_bytes {
let c = pictor_raster::compress_to(&img, format, target, &limits)?;
(c.bytes, c.format)
@@ -391,7 +396,8 @@ pub fn dispatch(state: &mut State, op: &str, a: Value) -> Result<Value, OpError>
let a: A = args(a)?;
let bytes = read_file(&a.input)?;
let stripped = pictor_meta::strip(&bytes)?;
let mut out = write_out(&a.output, &stripped.bytes, if a.overwrite { SaveMode::Overwrite } else { SaveMode::New })?;
let mut out =
write_out(&a.output, &stripped.bytes, if a.overwrite { SaveMode::Overwrite } else { SaveMode::New })?;
out["removed"] = json!(stripped.removed);
Ok(out)
}