tonhowtf/omniget · error

escolha pelo menos um print

Error message

escolha pelo menos um print

What it means

Thrown by stitch when the frames slice is empty — there are no screenshots to sew together, so no output canvas can be created. This is a fast-fail guard at the top of the public stitch() entry point, checked before any direction/overlap logic runs.

Solutions

  1. Ensure at least one decoded RgbaImage is passed to stitch; validate frames.len() >= 1 at the call site.
  2. If loading from files, check that the loader reported successful opens and didn't silently skip all files.
  3. Guard in the UI: require at least one selected screenshot before invoking run().
  4. Log the frames count before stitching to catch empty-input paths early.

Example fix

// before
let (img, seams) = image_stitch::stitch(&frames, &opts, &progress)?; // frames: vec![]
// after
if frames.is_empty() {
    anyhow::bail!("selecione pelo menos um print antes de costurar");
}
let (img, seams) = image_stitch::stitch(&frames, &opts, &progress)?;
Defensive patterns

Strategy: validation

Validate before calling

fn can_stitch(frames: &[image::RgbaImage]) -> bool { !frames.is_empty() }
// call stitch/run only if can_stitch(&frames)

Try / catch

match image_stitch::run(&files, &opts, &progress) {
    Err(e) if e.to_string().contains("escolha pelo menos um print") => {
        eprintln!("selecione capturas antes de costurar");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling stitch(&[], &opts, &progress) directly, or via run() after upstream loading produced zero successfully decoded frames (e.g. all files failed to open and were filtered out).

Common situations: Glob/folder passed to the stitch wrapper matched nothing; every frame failed to decode upstream and the empty vec was passed through; a caller constructed frames programmatically and forgot to push.

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/a8f77d9b8de3d870. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/image_stitch.rs:312

    let bg = super::icon_pack::parse_hex(&opts.background);
    let mut canvas = RgbaImage::from_pixel(width, height, bg);
    for (img, top) in drawn.iter().zip(&tops) {
        let x = align_offset(width, img.width(), align);
        imageops::overlay(&mut canvas, img, x, top - shift);
    }
    (canvas, seams)
}

/// Costura a lista já carregada. Fica separada do `run` para os testes não
/// precisarem de arquivo em disco.
pub fn stitch(
    frames: &[RgbaImage],
    opts: &StitchOptions,
    progress: &ProgressFn,
) -> anyhow::Result<(RgbaImage, Vec<StitchSeam>)> {
    if frames.is_empty() {
        return Err(anyhow!("escolha pelo menos um print"));
    }
    if opts.direction == "horizontal" {
        // Girando 90° no sentido horário, a borda direita vira o rodapé e a
        // esquerda vira o topo — exatamente o que a costura vertical espera.
        // O eixo curto inverte junto, então o alinhamento troca de ponta.
        let turned: Vec<RgbaImage> = frames.iter().map(imageops::rotate90).collect();
        let align = match opts.align.as_str() {
            "start" => "end",
            "end" => "start",
            other => other,
        };
        let (canvas, seams) = stitch_vertical(&turned, opts, align, progress);
        Ok((imageops::rotate270(&canvas), seams))
    } else {
        Ok(stitch_vertical(frames, opts, &opts.align, progress))
    }
}

View on GitHub (pinned to 8600b91f42)