1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use File;
use ;
use Path;
use ;
/// 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
///
/// ```rust
/// # use std::fs::File;
/// # use std::io::{Result, Read};
/// # fn main() -> Result<()> {
/// let mut file = File::open("./tests/images/example.png")?;
/// println!("{:?}", imghdr::from_reader(file));
/// # Ok(())
/// # }
/// ```
/// Open file and try to determine if it is an image.
///
/// Available only with `std` feature (enabled by default).
///
/// # Errors
///
/// This function will return an `Err(std::io::Error)` if file is inaccessible or can't be read.
///
/// # Examples
///
/// ```rust
/// let result = imghdr::from_file("./tests/images/example.jpg");
///
/// println!("{:#?}", result);
/// ```