/rust-imgtype

Get Image Type from Buffer

Primary LanguageRust

#rust-imgtype Build Status

Finds your image type by looking at the files header. No external dependencies.

###Supported Types

pub enum ImageType { JPEG, PNG, WEBP, GIF, TIFF }

###Example

extern crate imgtype;

use imgtype;
use imgtype::ImageType;

fn print_imgtype(file:&[u8]) {

    let img_type:Option<ImageType> = imgtype::from_buffer(file);

    match img_type {
        Some(img_type) => println!("Image Type is {}!", img_type),
        None           => println!("Unknown Image Type.")
    };

}

###Cargo.toml

[dependencies.imgtype]
git = "https://github.com/abustin/rust-imgtype"