{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin.rs","lineNumber":83,"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":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/f2074595a281bc057525c748175c8eb9805b0673/crates/codex-plus-core/src/dream_skin.rs#L65-L101","documentation":"macOS-only: after sips conversion, the prepared JPEG must stay at or under DREAM_SKIN_PREPARED_LIMIT (16 MiB). Large-dimension HEIC/TIFF sources (allowed up to 50 MiB pre-conversion) can re-encode to JPEGs past 16 MiB; the oversized prepared copy is deleted before the error propagates.","triggerScenarios":"Importing very large TIFF/HEIC scans or panoramas whose JPEG re-encode exceeds 16 MiB.","commonSituations":"Scanned artwork; panorama stitches; full-resolution pro-camera HEIC files.","solutions":["Downscale the source (longest edge around 8K or less) and retry","Export at lower JPEG quality or as compressed PNG","Crop to the region you actually want as skin and retry"],"exampleFix":"// before\nimport_dream_skin_image(state_dir, dir, stem, &huge_tiff)?;\n\n// after: bound dimensions first\nstd::process::Command::new(\"/usr/bin/sips\")\n    .arg(\"-Z\").arg(\"7680\")\n    .arg(&huge_tiff)\n    .arg(\"--out\").arg(&downscaled)\n    .status()?;\nimport_dream_skin_image(state_dir, dir, stem, &downscaled)?;","handlingStrategy":"validation","validationCode":"fn prepared_likely_fits(source: &std::path::Path) -> bool {\n    // heuristic: already-compressed sources rarely blow past the 16 MiB prepared cap\n    std::fs::symlink_metadata(source)\n        .map(|m| m.len() <= 12 * 1024 * 1024)\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-downscale wallpaper-scale images before importing on macOS","Remember the two-tier limit: 50 MiB source, 16 MiB prepared JPEG"],"tags":["dream-skin","macos","file-size-limit","image-conversion","rust"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"f2074595a281bc057525c748175c8eb9805b0673","analyzedAt":"2026-08-23T12:52:24.489Z","contentChangedAt":"2026-08-23T12:52:24.489Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}