pub fn decode_raw_image_from_any_bytes(image_bytes: &[u8]) -> ResultRawImageDecodeImageError {
/// JPEG has no alpha channel, so alpha is dropped and BGR orders are swapped into the L8 or Rgb8 the encoder takes.
RawImageFormat::RG8 => Some((Cow::Owned(pixels.chunks_exact(2).map(|px| px[0]).collect()), L8)),
let Ok(width) = u32::try_from(image.width) else { return ResultU8VecEncodeImageError::Err(EncodeImageError::DimensionError) };
let Ok(height) = u32::try_from(image.height) else { return ResultU8VecEncodeImageError::Err(EncodeImageError::DimensionError) };
let Ok(width) = u32::try_from(image.width) else { return ResultU8VecEncodeImageError::Err(EncodeImageError::DimensionError) };
let Ok(height) = u32::try_from(image.height) else { return ResultU8VecEncodeImageError::Err(EncodeImageError::DimensionError) };
/// Camera, screen and render frames are RGBA or BGRA, so JPEG drops their alpha instead of refusing them.