[][src]Function imghdr::from_reader

pub fn from_reader<T: Read>(f: T) -> Result<Option<Type>>

Try to determine image format from an IO stream of bytes.

Available only with std feature (enabled by default).

Returns

  • Ok(Some(Type)) if it is a known image format
  • Ok(None) if it is probably not an image
  • Err(..) if failed to read minimal bytes amount for a guess

Examples

let mut file = File::open("./tests/images/example.png")?;
println!("{:?}", imghdr::from_reader(file));