Function pb_imgsize::read_bytes
source · pub fn read_bytes(data: &[u8]) -> Result<ImageMetadata, DecodingError>
Expand description
Reads the dimensions and comments of an image from a byte slice.
This function reads the dimensions and comments of an image from a byte
slice. It returns an ImageMetadata
struct containing the width and height
of the image, as well as any comments found in the image.
Arguments
data
- A byte slice containing the image data.
Examples
use pb_imgsize::read_bytes;
let data = include_bytes!("buttercups.jpg");
let metadata = read_bytes(data)?;
assert_eq!(metadata, pb_imgsize::ImageMetadata {
width: 512,
height: 341,
comments: vec![b"Buttercups".to_vec()]
});