Function imagesize::get_dimensions
[−]
[src]
pub fn get_dimensions<P>(path: P) -> ImageResult<Dimensions> where
P: AsRef<Path>,
Get the image dimensions from a local file.
Arguments
path
- A local path to the file to parse.
Remarks
This method 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 first byte of the header isn't recognized as a supported image
- The data isn't long enough to find the dimensions for the given format
Examples
use imagesize::get_dimensions; match get_dimensions("test/test.webp") { Ok(dim) => { assert_eq!(dim.width, 716); assert_eq!(dim.height, 716); } Err(why) => println!("Error getting dimensions: {:?}", why) }