[][src]Function imagesize::size

pub fn size<P>(path: P) -> ImageResult<ImageSize> where
    P: AsRef<Path>, 

Get the image size from a local file

Arguments

  • path - A local path to the file to parse.

Remarks

Will try to read as little of the file as possible in order to get the proper size information.

Error

This method will return an ImageError under the following conditions:

  • The header isn't recognized as a supported image format
  • The data isn't long enough to find the size for the given format

Examples

use imagesize::size;

match size("test/test.webp") {
    Ok(dim) => {
        assert_eq!(dim.width, 716);
        assert_eq!(dim.height, 716);
    }
    Err(why) => println!("Error getting size: {:?}", why)
}