Skip to main content

extract_embedded_preview

Function extract_embedded_preview 

Source
pub fn extract_embedded_preview(
    bytes: &[u8],
    ext: &str,
) -> Result<Option<EmbeddedPreview>, MediaError>
Expand description

Extract the embedded preview of a RAW still, behind the pixel budget and the unwind guard.

Ok(None) when the bytes are a still that is not RAW, or a RAW that carries no embedded JPEG. Reads no sensor data, so it works for a RAW variant whose pixels this build cannot decode, provided the family is one it decodes.

The bounds are the ones every input gets: the IFD walk before RawFile::open, and before the thumbnail read, the walk’s largest stated JPEG length held to the file’s own length (the reader allocates it before it reads); then the JPEG’s header is probed and its frame held to MAX_DECODE_PIXELS, so a renderer that decodes it allocates no more than any other still.

§Errors

MediaError::NotAStillImage and MediaError::UnsupportedFormat as Decoder::probe, MediaError::PixelBudgetExceeded for a preview frame over budget, MediaError::Decode for a RAW or a preview that does not read, and MediaError::DecoderPanic when the reader panics. Every one leaves the rung to the next source.