tonhowtf/omniget · error

não abri

Error message

não abri {}: {}

What it means

Thrown by slice when image::open fails on the gathered spritesheet input. The error carries the input path and the underlying image::ImageError, e.g. the file does not exist, is not a decodable image, or has an unsupported format.

Solutions

  1. Confirm the file exists and is a valid image (try opening it in a viewer or with `file path`).
  2. Enable the corresponding image crate feature (jpeg, webp, etc.) if the format is unsupported.
  3. Re-download or re-export the corrupted file.
  4. Read the wrapped image::ImageError in the message to distinguish NotFound vs Unsupported vs Decode errors.

Example fix

// before
let sheet = image::open(input).map_err(|e| anyhow!("não abri {}: {}", input.display(), e))?;
// after
if !input.exists() {
    return Err(anyhow!("arquivo não encontrado: {}", input.display()));
}
let sheet = image::open(input).map_err(|e| anyhow!("não abri {}: {}", input.display(), e))?;
Defensive patterns

Strategy: validation

Validate before calling

fn readable_image(p: &std::path::Path) -> bool {
    p.is_file() && image::image_dimensions(p).is_ok()
}
// check readable_image(input) before run()

Try / catch

match image_sprite::run(&opts, &progress) {
    Err(e) if format!("{e}").contains("não abri") => {
        eprintln!("arquivo inválido ou formato não suportado: {e:#}");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling run() with mode "slice" where the first gathered file is missing, corrupted, has a wrong extension, or is an unsupported image format for the `image` crate.

Common situations: Corrupted downloads; files with misleading extensions (e.g. a .png that is actually a webp variant not compiled in); locked files on Windows; images with features disabled in the image crate build (no jpeg/webp feature).

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/3afa19f6e04f47f6. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/image_sprite.rs:346

        "frames": serde_json::Value::Object(map),
        "meta": {
            "app": "OmniGet",
            "image": sheet,
            "format": "RGBA8888",
            "size": { "w": w, "h": h },
            "scale": "1"
        }
    }))
    .unwrap_or_else(|_| "{}".into())
}

fn slice(opts: &SpriteOptions, progress: &ProgressFn) -> anyhow::Result<SpriteResult> {
    let files = gather(opts);
    let input = files
        .first()
        .ok_or_else(|| anyhow!("escolha o spritesheet"))?;
    let sheet = image::open(input)
        .map_err(|e| anyhow!("não abri {}: {}", input.display(), e))?
        .to_rgba8();
    let grid = Grid {
        cols: opts.cols,
        rows: opts.rows,
        cell_w: opts.cell_w,
        cell_h: opts.cell_h,
        margin: opts.margin,
        spacing: opts.spacing,
    };
    let cells = grid_cells(sheet.width(), sheet.height(), &grid);
    if cells.is_empty() {
        return Err(anyhow!("a grade não cabe nessa folha"));
    }

    let stem = if opts.name.trim().is_empty() {
        input
            .file_stem()
            .map(|s| s.to_string_lossy().to_string())

View on GitHub (pinned to 8600b91f42)