diff --git a/src/main.rs b/src/main.rs
@@ -1,6 +1,7 @@
use crossterm::style::Stylize;
use image::{DynamicImage, io::Reader as ImageReader};
use std::{
+ cmp::min,
env,
fmt::{self, Display},
fs::{self, File},
@@ -187,7 +188,7 @@ fn render_gallery(pics: Vec<Picture>) -> ExitCode {
}
// ========================================================================
- let num_threads = num_cpus::get() + 1;
+ let num_threads = min(num_cpus::get() + 1, pics.len());
let rendering_pool = ThreadPool::with_name(
String::from("thumbnails renderer"),
num_threads