imghdr

Library that determines the type of image contained in a file or byte stream, basically clone of the Python imghdr module.

Build Status License

Documentation is here.

Examples

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 = vec![]; file.readtoend(&mut content).unwrap();

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"),
}

} ```