This is my first pet rust project and it is a clone of the python' imghdr module, which is trying to determine image type by its first bytes.
Small example would describe it better:
extern crate imghdr;
fn main() {
match imghdr::open("/path/to/image.png") {
Ok(imghdr::Type::Png) => println!("Yep, it is a png"),
Ok(imghdr::Type::Jpg) => println!("Wow, it is a jpeg spy!"),
_ => println!("Some other format or even not an image at all"),
}
}
It is not so big deal, I know, but can be useful sometimes I'm still working on the additional image formats recognition and I would appreciate any feedback.
Links: crates.io, repository and documentation.