Library that determines the type of image contained in a file or byte stream, basically clone of the Python imghdr module.
Documentation is here.
Check a file directly:
```rust extern crate imghdr;
fn main() { match imghdr::open("/path/to/image.png") { Ok(imghdr::Type::Png) => println!("Yep, it is a PNG"), _ => println!("Nope, it is definitely not a PNG"), } } ```
Or check a byte stream:
```rust extern crate imghdr;
fn main() {
let mut file = File::open("/path/to/image.png").unwrap();
let mut content: Vec
match imghdr::what(content.as_slice()) {
Some(imghdr::Type::Jpg) => println!("And this is a Jpeg"),
_ => println!("Can a Png, Bmp or other file format"),
}
} ```