correction + regexp

This commit is contained in:
2026-05-20 23:34:50 +02:00
parent d173db3342
commit 595d025160
6 changed files with 317 additions and 74 deletions

View File

@ -9,6 +9,8 @@ use std::thread;
use std::time::{Duration, SystemTime};
use uuid::Uuid;
const MAX_IMAGE_PIXELS: usize = 3840 * 2160;
fn hash_bytes(data: &[u8]) -> u64 {
let mut hasher = DefaultHasher::new();
data.hash(&mut hasher);
@ -47,6 +49,21 @@ pub fn start(db: Arc<Mutex<Database>>, mut clipboard: Clipboard) -> Result<(), B
continue;
};
let pixel_count = img_data.width * img_data.height;
if pixel_count > MAX_IMAGE_PIXELS {
eprintln!(
"Image ignorée : {}×{} ({} Mpx > limite {}×{})",
img_data.width,
img_data.height,
pixel_count / 1_000_000,
3840,
2160
);
last_image_hash = Some(pixel_count as u64);
last_text = None;
continue;
}
let hash = hash_bytes(&img_data.bytes);
if Some(hash) == last_image_hash {
continue;