Function pb_imgsize::read_file
source · pub fn read_file(path: impl AsRef<Path>) -> Result<ImageMetadata, Error>
Expand description
Reads the dimensions and comments of an image from a file.
This function reads the dimensions and comments of an image from a file. It
returns an ImageMetadata
struct containing the width and height of the
image, as well as any comments found in the image.
Note: This function works by reading the entire file into memory.
Arguments
path
- A path to the image file.
Examples
let metadata = pb_imgsize::read_file("src/buttercups.jpg")?;
assert_eq!(metadata, pb_imgsize::ImageMetadata {
width: 512,
height: 341,
comments: vec![b"Buttercups".to_vec()],
});