
- Updated the app description in package.json and Cargo.toml to "Screenshots that organize themselves". - Refactored the Tauri backend to introduce a new command for handling folder selection and watching for PNG file changes. - Added utility functions for processing PNG files and managing the watcher state. - Improved the frontend by integrating an ImageViewer component and setting up event listeners for search input focus.
23 lines
764 B
Rust
23 lines
764 B
Rust
use base64::{engine::general_purpose::STANDARD as BASE64, Engine as _};
|
|
use std::fs;
|
|
use std::path::PathBuf;
|
|
use tauri::{AppHandle, Emitter};
|
|
|
|
pub fn process_png_file(path: &PathBuf, app: AppHandle) -> Result<(), String> {
|
|
println!("Processing PNG file: {}", path.display());
|
|
|
|
// Read the file
|
|
let contents = fs::read(path).map_err(|e| format!("Failed to read file: {}", e))?;
|
|
|
|
// Convert to base64
|
|
let base64_string = BASE64.encode(&contents);
|
|
println!("Generated base64 string of length: {}", base64_string.len());
|
|
|
|
// Emit the base64 to frontend
|
|
app.emit("png-processed", base64_string)
|
|
.map_err(|e| format!("Failed to emit event: {}", e))?;
|
|
|
|
println!("Successfully processed file: {}", path.display());
|
|
Ok(())
|
|
}
|