home ~ socials ~ projects ~ rss

Get The Size Of An Image In Rust

April 2023
use imagesize::size;

fn main() {
    let img = size("image_test/tmp.png").unwrap();
    dbg!(img.width);
    dbg!(img.height);

}

use: crate add imagesize to get the crate installed.

end of line
Share link:
https://www.alanwsmith.com/en/2o/de/g6/fn/?get-the-size-of-an-image-in-rust