I want to merge two images. I'm using image::imageops::overlay
from the image crate:
use image::imageops::overlay;
use std::path::Path;
fn main() {
let path1 = Path::new("~/Desktop/to-merge/image1.png");
let path2 = Path::new("~/Desktop/to-merge/image2.png");
let mut img1 = image::open(&path1).unwrap().clone();
let mut img2 = image::open(&path2).unwrap().clone();
let output = overlay(&mut img1, &mut img2, 0, 0);
let save_path = Path::new("~/Desktop/to-crop/merged.png");
output.save(save_path).unwrap();
}
After hitting cargo run
, I get this error:
error[E0599]: no method named `save` found for unit type `()` in the current scope
--> src/main.rs:11:12
|
11 | output.save(save_path).unwrap();
| ^^^^ method not found in `()`
I think the compiler is saying image::imageops::overlay
doesn't have the method save()
? If so, what should I use instead?