teaql_tool_extra/
image.rs1use teaql_tool_core::{Result, TeaQLToolError};
2use image::imageops::FilterType;
3
4#[derive(Debug, Clone)]
5pub struct ImageTool;
6
7impl ImageTool {
8 pub fn new() -> Self { Self }
9
10 pub fn resize(&self, input_path: &str, output_path: &str, width: u32, height: u32) -> Result<()> {
11 let img = image::open(input_path).map_err(|e| TeaQLToolError::ExecutionError(e.to_string()))?;
12 let resized = img.resize(width, height, FilterType::Lanczos3);
13 resized.save(output_path).map_err(|e| TeaQLToolError::ExecutionError(e.to_string()))?;
14 Ok(())
15 }
16}
17
18impl Default for ImageTool {
19 fn default() -> Self { Self::new() }
20}