Skip to content

Latest commit

 

History

History
26 lines (16 loc) · 827 Bytes

overlaying_images.md

File metadata and controls

26 lines (16 loc) · 827 Bytes

Overlaying Images

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:

overlay

Use overlay_bounds for more control on how to overlay the image.

➡️ Next: Tiling Images

📘 Back: Table of contents