feat: implement image tools (compress, resize, convert) and PDF tools (merge, split, images-to-pdf)
Image tools now actually process images: - Compress: re-encode JPEG with configurable quality - Resize: Lanczos3 resize with fit modes (inside/fill/crop) - Convert: cross-format conversion (JPEG/PNG/WebP/GIF/BMP) PDF tools: - Merge: combine multiple PDFs into one document - Split: extract page ranges via pagespec (1-3,5,7-9) - Images to PDF: embed images as JPEG in A4 pages with scaling - Compress: re-save PDF with optimized cross-reference table Also fix metrics format to emit default zero values. Co-Authored-By: Kilo <kilo@kilo.ai>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use lopdf::Document;
|
||||
|
||||
use crate::nats::progress::ProgressReporter;
|
||||
|
||||
/// Compress PDF by re-saving with compression.
|
||||
pub async fn process(
|
||||
input_path: &Path,
|
||||
_options: &serde_json::Value,
|
||||
output_dir: &PathBuf,
|
||||
_progress: &ProgressReporter,
|
||||
) -> Result<PathBuf, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let mut doc = Document::load(input_path)?;
|
||||
|
||||
let output_path = output_dir.join(format!("compressed_{}", input_path.file_name().unwrap_or_default().to_string_lossy()));
|
||||
doc.save_to(&mut std::fs::File::create(&output_path)?)?;
|
||||
|
||||
Ok(output_path)
|
||||
}
|
||||
Reference in New Issue
Block a user