{"record":{"id":"ceb70696d0c84389","repo":"bevyengine/bevy","slug":"cannot-compress-an-uninitialized-image","errorCode":null,"errorMessage":"Cannot compress an uninitialized image","messagePattern":"Cannot compress an uninitialized image","errorType":"exception","errorClass":"CompressedImageSaverError","httpStatus":null,"severity":"error","filePath":"crates/bevy_image/src/compressed_image_saver/mod.rs","lineNumber":212,"sourceCode":"    Straight,\n    /// The image has an alpha channel, and the RGB channels have been premultiplied by the alpha value.\n    Premultiplied,\n    /// The image has no alpha channel.\n    Opaque,\n}\n\n/// Errors encountered when writing compressed images via [`CompressedImageSaver`].\n#[non_exhaustive]\n#[derive(Debug, Error, TypePath)]\npub enum CompressedImageSaverError {\n    /// I/O error.\n    #[error(transparent)]\n    Io(#[from] std::io::Error),\n    /// The underlying compression library returned an error.\n    #[error(transparent)]\n    CompressionFailed(Box<dyn core::error::Error + Send + Sync>),\n    /// Attempted to save an image with uninitialized data.\n    #[error(\"Cannot compress an uninitialized image\")]\n    UninitializedImage,\n    /// The texture format is not supported for compression.\n    #[error(\"Unsupported texture format for compression: {0:?}\")]\n    UnsupportedFormat(TextureFormat),\n    /// `is_normal_map` was set, but the input [`Image`]'s `texture_descriptor.format` is an sRGB\n    /// variant (e.g. `Rgba8UnormSrgb`). Normal maps must be stored as linear vector data. Typically this means\n    /// configuring the [`ImageLoaderSettings`] with `is_srgb: false` for this image.\n    #[error(\n        \"Cannot compress an sRGB texture ({0:?}) as a normal map; \\\n         the input Image's texture_descriptor.format must be a non-sRGB (linear) variant\"\n    )]\n    NormalMapMustBeLinear(TextureFormat),\n}\n","sourceCodeStart":194,"sourceCodeEnd":226,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_image/src/compressed_image_saver/mod.rs#L194-L226","documentation":"CompressedImageSaverError::UninitializedImage: the CompressedImageSaver was asked to compress an Image whose data buffer is not yet initialized (e.g. created with uninit data and never filled), which compression cannot handle.","triggerScenarios":"Thrown at crates/bevy_image/src/compressed_image_saver/mod.rs:212 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fully write the image pixel data before saving","Avoid RenderAssetUsages/main-thread patterns that leave image data uninit when saving","Handle the Result from the asset writer and report the faulty asset"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}