tonhowtf/omniget · error

escolha as imagens ou a pasta

Error message

escolha as imagens ou a pasta

What it means

Empty-input guard in the sprite batch mode: batch() collects candidate images with gather(opts) and aborts when none are found, before any packing work. It fires when the user provides neither image files nor a folder (or the given folder/paths yield no images), so there is nothing to build a sheet from.

Solutions

  1. Set input to a folder with images or a pattern that matches at least one image.
  2. Confirm gather() accepts the file extensions present in the folder.
  3. Validate input presence in the UI/CLI before calling run().
  4. Check gather()'s recursion settings if images live in subdirectories.

Example fix

// before
let files = gather(&opts); // empty folder
image_sprite::run(&opts, &progress)?;
// after
if gather(&opts).is_empty() {
    anyhow::bail!("a pasta/padrão não contém imagens");
}
image_sprite::run(&opts, &progress)?;
Defensive patterns

Strategy: validation

Validate before calling

fn has_images(opts: &SpriteOptions) -> bool { !gather(opts).is_empty() }
// call run() only if has_images(&opts)

Try / catch

match image_sprite::run(&opts, &progress) {
    Err(e) if e.to_string().contains("escolha as imagens") => prompt_folder_selection(),
    other => other?,
}

Prevention

When it happens

Trigger: Calling run() with mode "batch" where opts input is empty, the folder is empty, or the pattern/extension filter excludes all files.

Common situations: User picks a folder that contains only subfolders or non-image files; wrong suffix/pattern config; folder path typo.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

    super::report(progress, "img-sprite", "done", total, Some(total), None);
    Ok(SpriteResult {
        mode: "pack".into(),
        count: frames.len() as u32,
        outputs,
        frames,
        sheet: Some(sheet_path.to_string_lossy().to_string()),
        atlas,
        width: sheet.width(),
        height: sheet.height(),
        skipped,
    })
}

fn batch(opts: &SpriteOptions, progress: &ProgressFn) -> anyhow::Result<SpriteResult> {
    let files = gather(opts);
    if files.is_empty() {
        return Err(anyhow!("escolha as imagens ou a pasta"));
    }
    let total = files.len() as u64;
    let mut outputs = Vec::new();
    let mut frames = Vec::new();
    let mut skipped = 0u32;
    let suffix = if opts.suffix.is_empty() {
        "-lote"
    } else {
        opts.suffix.as_str()
    };
    for (i, path) in files.iter().enumerate() {
        super::report(
            progress,
            "img-sprite",
            "progress",
            i as u64,
            Some(total),
            Some(path.to_string_lossy().to_string()),

View on GitHub (pinned to 8600b91f42)