bevyengine/bevy · error · HdrTextureLoaderError

Could not extract image: {0}

Error message

Could not extract image: {0}

What it means

HdrTextureLoaderError decoding variant: the HDR file was read but its pixel data could not be extracted/decoded into an Image (malformed or unsupported HDR payload).

Source

Thrown at crates/bevy_image/src/hdr_texture_loader.rs:29

#[derive(Clone, Default, TypePath)]
pub struct HdrTextureLoader;

/// Settings for [`HdrTextureLoader`].
#[derive(Serialize, Deserialize, Default, Debug)]
pub struct HdrTextureLoaderSettings {
    /// Where the asset will be used - see the docs on [`RenderAssetUsages`] for details.
    pub asset_usage: RenderAssetUsages,
}

/// Possible errors that can be produced by [`HdrTextureLoader`]
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum HdrTextureLoaderError {
    /// I/O Error.
    #[error("Could load texture: {0}")]
    Io(#[from] std::io::Error),
    /// Failed to decode the texture.
    #[error("Could not extract image: {0}")]
    Image(#[from] image::ImageError),
}

impl AssetLoader for HdrTextureLoader {
    type Asset = Image;
    type Settings = HdrTextureLoaderSettings;
    type Error = HdrTextureLoaderError;
    async fn load(
        &self,
        reader: &mut dyn Reader,
        settings: &Self::Settings,
        _load_context: &mut LoadContext<'_>,
    ) -> Result<Image, Self::Error> {
        let format = TextureFormat::Rgba32Float;
        // `Rgba32Float` will always return a valid pixel size
        let pixel_size = format.pixel_size().unwrap();
        debug_assert_eq!(pixel_size, 4 * 4, "Format should have 32bit x 4 size");

View on GitHub (pinned to 396ca72708)

Solutions

  1. Re-save the .hdr file with a mainstream encoder
  2. Check the file is actually Radiance HDR format
  3. Handle the loader error and use a fallback texture
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/bevy_image/src/hdr_texture_loader.rs:29 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/e309de377cafe7de. Report an issue: GitHub.