We can use image::open to load an image file and use save to save an image.
fn main() {
let img = image::open("my_image.jpg").unwrap();
img.save("saved_image.png").unwrap();
}
The save method derives the image format from the file extension automatically. Check here to see all the supported image formats.
We can also use save_with_format to save an image with an explicitly specified image format.
➡️ Next: Loading And Saving Images In Memory
📘 Back: Table of contents