BigPizzaV3/CodexPlusPlus · error · anyhow::Error

prepared Dream Skin image exceeds 16 MiB

Error message

prepared Dream Skin image exceeds 16 MiB

What it means

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.

Source

Thrown at crates/codex-plus-core/src/dream_skin.rs:83

            "failed to create Dream Skin theme directory {}",
            destination_dir.display()
        )
    })?;

    let (prepared_path, prepared_extension) = prepare_image(source, destination_dir, &extension)?;
    let prepared_metadata = std::fs::metadata(&prepared_path).with_context(|| {
        format!(
            "failed to read prepared image metadata {}",
            prepared_path.display()
        )
    })?;
    if prepared_metadata.len() == 0 {
        remove_prepared_copy(source, &prepared_path);
        bail!("prepared Dream Skin image is empty");
    }
    if prepared_metadata.len() > DREAM_SKIN_PREPARED_LIMIT {
        remove_prepared_copy(source, &prepared_path);
        bail!("prepared Dream Skin image exceeds 16 MiB");
    }

    let destination = destination_dir.join(format!("{destination_stem}.{prepared_extension}"));
    let bytes = std::fs::read(&prepared_path)
        .with_context(|| format!("failed to read prepared image {}", prepared_path.display()))?;
    crate::settings::atomic_write(&destination, &bytes)
        .with_context(|| format!("failed to store Dream Skin image {}", destination.display()))?;
    remove_prepared_copy(source, &prepared_path);
    Ok(destination)
}

pub fn clear_managed_dream_skin_image(state_dir: &Path) -> anyhow::Result<()> {
    let managed_dir = state_dir.join(MANAGED_THEME_DIR);
    if !managed_dir.is_dir() {
        return Ok(());
    }
    for entry in std::fs::read_dir(&managed_dir)
        .with_context(|| format!("failed to read {}", managed_dir.display()))?

View on GitHub (pinned to f2074595a2)

Solutions

  1. Downscale the source (longest edge around 8K or less) and retry
  2. Export at lower JPEG quality or as compressed PNG
  3. Crop to the region you actually want as skin and retry

Example fix

// before
import_dream_skin_image(state_dir, dir, stem, &huge_tiff)?;

// after: bound dimensions first
std::process::Command::new("/usr/bin/sips")
    .arg("-Z").arg("7680")
    .arg(&huge_tiff)
    .arg("--out").arg(&downscaled)
    .status()?;
import_dream_skin_image(state_dir, dir, stem, &downscaled)?;
Defensive patterns

Strategy: validation

Validate before calling

fn prepared_likely_fits(source: &std::path::Path) -> bool {
    // heuristic: already-compressed sources rarely blow past the 16 MiB prepared cap
    std::fs::symlink_metadata(source)
        .map(|m| m.len() <= 12 * 1024 * 1024)
        .unwrap_or(false)
}

Prevention

When it happens

Trigger: Importing very large TIFF/HEIC scans or panoramas whose JPEG re-encode exceeds 16 MiB.

Common situations: Scanned artwork; panorama stitches; full-resolution pro-camera HEIC files.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23). Data as JSON: /api/errors/6efd0d239b79901c. Report an issue: GitHub.