Skip to content

Commit 58495bc

Browse files
author
Mikachu2333
committed
Supress little_exif images without EXIF
1 parent 3704c45 commit 58495bc

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

src/main.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,24 @@ fn main() {
269269
let input_modified = get_file_modified_time(&input);
270270

271271
let img = handle_error!(input, decode(&input));
272-
let exif_metadata = ExifMetadata::new_from_path(&input).ok();
272+
let exif_metadata: Option<ExifMetadata> = {
273+
// Temporarily suppress little_exif error logs for images without EXIF
274+
let prev_level = log::max_level();
275+
log::set_max_level(log::LevelFilter::Off);
276+
let result = ExifMetadata::new_from_path(&input);
277+
log::set_max_level(prev_level);
278+
279+
match result {
280+
Ok(exif) => {
281+
if strip_metadata {
282+
None
283+
} else {
284+
Some(exif)
285+
}
286+
}
287+
Err(_) => None,
288+
}
289+
};
273290

274291
pb.set_style(sty_aux_operations.clone());
275292

@@ -352,17 +369,12 @@ fn main() {
352369
available_encoder.encode(&pipeline.images()[0], output_file)
353370
);
354371

355-
exif_metadata
356-
.and_then(|mut metadata| {
357-
if strip_metadata {
358-
metadata.reduce_to_a_minimum();
359-
}
360-
metadata.write_to_file(&output).ok()
361-
})
362-
.or_else(|| {
363-
log::info!("No metadata found, skipping...");
364-
None
365-
});
372+
if let Some(actual_metadata) = exif_metadata {
373+
match actual_metadata.write_to_file(&output) {
374+
Ok(_) => {}
375+
Err(e) => log::error!("{}", e),
376+
}
377+
}
366378

367379
let output_size = handle_error!(output, output.metadata()).len();
368380
let processing_time = image_start_time.elapsed().as_millis();

0 commit comments

Comments
 (0)