Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 1.06 KB

loading_and_saving_image_files.md

File metadata and controls

25 lines (17 loc) · 1.06 KB

Loading And Saving Image Files

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();
}

my_image.jpg: my_image

saved_image.png: saved_image

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