Skip to main content

decode_image

Function decode_image 

Source
pub fn decode_image(bytes: &[u8]) -> Result<DecodedImage, ImageError>
Expand description

Decode container bytes to raw RGB. The format is auto-detected from the bytes’ header.

Only formats whose cargo features are enabled will be recognised — e.g. with just png on, this can decode PNG but not WebP. AVIF decoding additionally requires image/avif-native (libdav1d) which is not enabled by our avif feature.

Pixels with alpha are dropped (the image crate decodes to RGBA internally and we keep only the RGB channels).

§Errors

Returns ImageError if the bytes are not in a recognised format or the decoder fails.