{"record":{"id":"6efd0d239b79901c","repo":"BigPizzaV3/CodexPlusPlus","slug":"prepared-dream-skin-image-exceeds-16-mib","errorCode":null,"errorMessage":"prepared Dream Skin image exceeds 16 MiB","messagePattern":"prepared Dream Skin image exceeds 16 MiB","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin.rs","lineNumber":84,"sourceCode":"            \"failed to create Dream Skin theme directory {}\",\n            destination_dir.display()\n        )\n    })?;\n\n    let (prepared_path, prepared_extension) = prepare_image(source, destination_dir, &extension)?;\n    let prepared_metadata = std::fs::metadata(&prepared_path).with_context(|| {\n        format!(\n            \"failed to read prepared image metadata {}\",\n            prepared_path.display()\n        )\n    })?;\n    if prepared_metadata.len() == 0 {\n        remove_prepared_copy(source, &prepared_path);\n        bail!(\"prepared Dream Skin image is empty\");\n    }\n    if prepared_metadata.len() > DREAM_SKIN_PREPARED_LIMIT {\n        remove_prepared_copy(source, &prepared_path);\n        bail!(\"prepared Dream Skin image exceeds 16 MiB\");\n    }\n\n    let destination = destination_dir.join(format!(\"{destination_stem}.{prepared_extension}\"));\n    let bytes = std::fs::read(&prepared_path)\n        .with_context(|| format!(\"failed to read prepared image {}\", prepared_path.display()))?;\n    crate::settings::atomic_write(&destination, &bytes)\n        .with_context(|| format!(\"failed to store Dream Skin image {}\", destination.display()))?;\n    remove_prepared_copy(source, &prepared_path);\n    Ok(destination)\n}\n\npub fn clear_managed_dream_skin_image(state_dir: &Path) -> anyhow::Result<()> {\n    let managed_dir = state_dir.join(MANAGED_THEME_DIR);\n    if !managed_dir.is_dir() {\n        return Ok(());\n    }\n    for entry in std::fs::read_dir(&managed_dir)\n        .with_context(|| format!(\"failed to read {}\", managed_dir.display()))?","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin.rs#L66-L102","documentation":"The prepared (transcoded) image must fit within DREAM_SKIN_PREPARED_LIMIT (16 MiB); when it exceeds this the function removes the prepared copy and bails. The limit bounds final theme asset size shipped/stored per directory.","triggerScenarios":"prepare_image produces an output larger than 16 MiB even though the source was under the 50 MiB source limit — e.g. transcoding a compressible JPEG into a huge lossless PNG — detected by the prepared_metadata.len() > DREAM_SKIN_PREPARED_LIMIT check.","commonSituations":"A large animated GIF or high-detail PNG that expands when re-encoded; preparing a 40 MiB JPEG into an uncompressed intermediate format; very high-resolution wallpapers.","solutions":["Start from a smaller/optimized source: resize to actual display dimensions before import.","Re-export the source as PNG or JPEG rather than GIF/WebP with huge frames, so the prepared output stays small.","Check which extension prepare_image produced and whether the conversion inflated size; pick a source format that transcodes compactly.","If 16 MiB is genuinely too small for your theme, raise DREAM_SKIN_PREPARED_LIMIT in dream_skin.rs."],"exampleFix":"// before: 30 MiB GIF transcoded to oversized output fails\nimport_dream_skin_image(\"big.gif\", dir, stem)?; // -> prepared exceeds 16 MiB\n// after: pre-shrink the source\n// magick big.gif -coalesce -resize 1920x1080 small.gif\nimport_dream_skin_image(\"small.gif\", dir, stem)?;","handlingStrategy":"validation","validationCode":"// pre-shrink the source so the prepared output stays under 16 MiB\nlet md = std::fs::metadata(&source)?;\nif md.len() > 8 * 1024 * 1024 {\n    // run: magick source.png -resize 3840x2160 -strip source_small.png\n    return import_dream_skin_image(Path::new(\"source_small.png\"), dir, stem);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import sources already sized to display resolution","Prefer PNG/JPEG sources over formats that inflate during transcoding (large GIFs)","Spot-check prepared output sizes once with a representative image before batch imports"],"tags":["image-processing","size-limit","filesystem"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}