Skip to main content

load_image_from_memory

Function load_image_from_memory 

Source
pub fn load_image_from_memory(
    bytes: &[u8],
) -> Result<ImageBuffer<Rgb<u8>, Vec<u8>>, OCRError>
Expand description

Loads an image from the given bytes and converts it to RgbImage.

This function decodes an image from a byte slice and converts it to an RgbImage. It handles any image format supported by the image crate.

§Arguments

  • bytes - A byte slice containing the encoded image data

§Returns

  • Ok(RgbImage) - The decoded and converted RGB image
  • Err(OCRError) - An error if the image could not be decoded or converted

§Errors

This function will return an OCRError::ImageLoad error if the image cannot be decoded from the provided bytes, or if there is an error during conversion.