{"record":{"id":"0d5dd2df535b5e45","repo":"tauri-apps/tauri","slug":"expected-rgba-image-data-found","errorCode":null,"errorMessage":"expected RGBA image data, found {}","messagePattern":"expected RGBA image data, found (.+?)","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/tauri/src/image/mod.rs","lineNumber":215,"sourceCode":"  /// the webview resources table.\n  pub fn into_img(self, resources_table: &ResourceTable) -> crate::Result<Arc<Image<'_>>> {\n    match self {\n      Self::Resource(rid) => resources_table.get::<Image<'static>>(rid),\n      #[cfg(any(feature = \"image-ico\", feature = \"image-png\"))]\n      Self::Path(path) => Image::from_path(path).map(Arc::new),\n\n      #[cfg(any(feature = \"image-ico\", feature = \"image-png\"))]\n      Self::Bytes(bytes) => Image::from_bytes(&bytes).map(Arc::new),\n\n      Self::Rgba {\n        rgba,\n        width,\n        height,\n      } => Ok(Arc::new(Image::new_owned(rgba, width, height))),\n\n      #[cfg(not(any(feature = \"image-ico\", feature = \"image-png\")))]\n      _ => Err(\n        std::io::Error::new(\n          std::io::ErrorKind::InvalidInput,\n          format!(\n            \"expected RGBA image data, found {}\",\n            match self {\n              JsImage::Path(_) => \"a file path\",\n              JsImage::Bytes(_) => \"raw bytes\",\n              _ => unreachable!(),\n            }\n          ),\n        )\n        .into(),\n      ),\n    }\n  }\n}\n","sourceCodeStart":197,"sourceCodeEnd":231,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri/src/image/mod.rs#L197-L231","documentation":"JsImage is the untagged deserialization target for image values sent from JavaScript (e.g. via transformImage). into_img converts it to an Image: the Path and Bytes variants need actual image decoding, which is only compiled in when the image-ico and/or image-png cargo features are enabled on tauri. With both features off, only the Rgba { rgba, width, height } variant converts, and Path/Bytes inputs fail with InvalidInput: 'expected RGBA image data, found a file path / raw bytes'.","triggerScenarios":"A Rust API that accepts JsImage and calls into_img (tray icons, window icons, custom plugins), built without tauri's image-ico and image-png features, while the frontend sends a file-path string or raw encoded bytes instead of { rgba, width, height }.","commonSituations":"Slimming default-features to cut binary size and silently dropping the image codecs; JS code passing a path string out of convenience; version upgrades where feature sets changed; a dependency disabling tauri default features via feature unification.","solutions":["Enable the decoding features in Cargo.toml: tauri = { version = \"2\", features = [\"image-png\", \"image-ico\"] }","Or change the frontend payload to raw RGBA: { rgba: Uint8Array, width, height }","Convert images to RGBA on the JS side with the transformImage API before invoking","Declare the features explicitly in your own Cargo.toml so feature unification cannot drop them"],"exampleFix":"# before (Cargo.toml)\ntauri = { version = \"2\", default-features = false }\n# after\ntauri = { version = \"2\", default-features = false, features = [\"image-png\", \"image-ico\"] }","handlingStrategy":"type-guard","validationCode":"// frontend: send the shape that works even without image features\nconst image = { rgba: Array.from(rgbaBytes), width, height }; // JsImage::Rgba\nawait invoke('set_tray_icon', { image });","typeGuard":"// Rust: only these variants can convert without image-ico/image-png features\nfn converts_without_image_features(img: &tauri::image::JsImage) -> bool {\n    matches!(\n        img,\n        tauri::image::JsImage::Rgba { .. } | tauri::image::JsImage::Resource(_)\n    )\n}","tryCatchPattern":"match js_image.into_img(&resources_table) {\n    Ok(image) => { /* use image */ }\n    Err(e) => {\n        // path/bytes rejected: enable tauri features image-png/image-ico,\n        // or make the frontend send { rgba, width, height }\n        log::warn!(\"image rejected: {e}\");\n    }\n}","preventionTips":["Declare features = [\"image-png\", \"image-ico\"] explicitly rather than relying on defaults or unification","Send RGBA payloads from JS when in doubt — they convert under every feature set","Re-check tauri's feature list after upgrades or after trimming default-features"],"tags":["image","cargo-features","rgba","javascript-interop","feature-flags"],"backgroundTag":"missing-cargo-feature","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","contentChangedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}