Skip to content

Commit

Permalink
Merge pull request #4 from ThibsG/add_webp_metadata_recopy_support
Browse files Browse the repository at this point in the history
Add WebP metadata recopy support
  • Loading branch information
ThibsG authored Dec 2, 2024
2 parents 8d8bcc5 + 70b0239 commit 2c380a2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use core::sync::atomic::{AtomicU64, Ordering};
use img_parts::webp::WebP;
use img_parts::{jpeg::Jpeg, png::Png};
use img_parts::{ImageEXIF, ImageICC};
use log::{debug, error};
Expand Down Expand Up @@ -157,6 +158,22 @@ fn recopy_metadata<P: AsRef<Path> + ?Sized + std::fmt::Debug>(
.write_to(&output_file)
.expect("cannot write to output jpg file");
}
"webp" => {
let input_webp = WebP::from_bytes(input.into()).expect("unable to get as webp");

let mut output_webp = WebP::from_bytes(output.into()).expect("unable to get as webp");
output_webp.set_exif(input_webp.exif());
output_webp.set_icc_profile(input_webp.icc_profile());

let output_file = OpenOptions::new()
.write(true)
.open(to)
.expect("unable to open webp as File");
output_webp
.encoder()
.write_to(&output_file)
.expect("cannot write to output webp file");
}
other => error!("Extension ({other}) not supported to get Exif metadata: {from:?}"),
}
Ok(())
Expand Down

0 comments on commit 2c380a2

Please sign in to comment.