Now we can iterate through an image

This commit is contained in:
Yash Karandikar 2021-09-07 10:03:58 -05:00
parent dd1673997e
commit 9ae89d21d2
Signed by: karx
GPG key ID: A794DA2529474BA5
2 changed files with 18 additions and 2 deletions

BIN
input.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View file

@ -1,3 +1,19 @@
fn main() {
println!("Hello, world!");
use image::io::Reader as ImageReader;
fn main() -> anyhow::Result<()> {
if let Some(filename) = std::env::args().nth(1) {
println!("{}", filename);
let img = ImageReader::open(filename)?.decode()?;
let rimage = img.to_rgb8();
for px in rimage.pixels() {
println!("[{}, {}, {}]", px[0], px[1], px[2]);
}
} else {
println!("Please provide a valid filename.");
}
Ok(())
}