To draw an image on top of another image, we can use overlay or replace (depending on whether pixels can be transparent or not).
use image::imageops;
fn main() {
let mut img1 = image::open("my_image.jpg").unwrap();
let img2 = image::open("my_image.jpg").unwrap();
imageops::overlay(&mut img1, &img2, 512, 384);
img1.save("overlay.jpg").unwrap();
}
overlay.jpg:
Use overlay_bounds for more control on how to overlay the image.
➡️ Next: Tiling Images
📘 Back: Table of contents