{"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":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/tauri/src/image/mod.rs","lineNumber":210,"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":192,"sourceCodeEnd":226,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri/src/image/mod.rs#L192-L226","documentation":"Image::into_img() converts a JsImage received from JS (path, raw bytes, or RGBA) into an internal RGBA Image. Without the image-ico/image-png features enabled, the only supported variant is already-decoded RGBA data; any other JsImage variant triggers this io::Error (InvalidInput) describing what was found instead.","triggerScenarios":"Calling an API that takes an image (e.g. set window icon, tray icon) from JS passing a file path or raw encoded bytes while the tauri crate was built without the `image-png`/`image-ico` features.","commonSituations":"Using default Cargo features that exclude image decoding; passing a PNG file path to setIcon from the frontend; disabling default features and forgetting to re-add image support.","solutions":["Enable the required Cargo features on the tauri crate: features = [\"image-png\"] (or \"image-ico\")","Alternatively, decode the image in JS/Rust yourself and pass raw RGBA data with width/height","Ensure the feature is enabled on the app crate, not only an intermediate workspace crate"],"exampleFix":"// before (Cargo.toml)\ntauri = \"2\"\n// after\ntauri = { version = \"2\", features = [\"image-png\"] }","handlingStrategy":"validation","validationCode":"// Before calling setIcon/setTrayIcon from JS, pass RGBA data or ensure features enabled\nconst isRgba = (img) => img instanceof ImageData;\nif (!isRgba(icon) && !import.meta.env.TAURI_IMAGE_FEATURES) {\n  throw new Error('enable tauri features image-png/image-ico or pass ImageData');\n}","typeGuard":"function isRgbaImage(v) { return v instanceof ImageData || (v && Array.isArray(v.rgba) && typeof v.width === 'number' && typeof v.height === 'number'); }","tryCatchPattern":"try {\n  await appWindow.setIcon(iconPath);\n} catch (e) {\n  if (String(e).includes('expected RGBA image data')) {\n    console.error('Enable tauri cargo feature image-png or pass RGBA ImageData', e);\n  }\n}","preventionTips":["Enable tauri features image-png/image-ico when using file paths or encoded bytes for icons","Prefer passing ImageData (raw RGBA) from the frontend for maximum portability","Add the feature flags to workspace Cargo.toml to avoid them being dropped in refactors"],"tags":["image","rust","cargo-features","invalid-input"],"backgroundTag":"feature-not-enabled","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}