pub fn load_image(
image: &[u8],
format: Option<PixelFormat>,
memory: Option<TensorMemory>,
) -> Result<TensorDyn>Expand description
Load an image from raw bytes (JPEG or PNG) and return a TensorDyn.
The optional format specifies the desired output pixel format (e.g.,
PixelFormat::Rgb, PixelFormat::Rgba); if None, the native
format of the file is used (typically RGB for JPEG).
ยงExamples
use edgefirst_image::load_image;
use edgefirst_tensor::PixelFormat;
let jpeg = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../testdata/zidane.jpg"));
let img = load_image(jpeg, Some(PixelFormat::Rgb), None)?;
assert_eq!(img.width(), Some(1280));
assert_eq!(img.height(), Some(720));