tonhowtf/omniget · error
a grade não cabe nessa folha
Error message
a grade não cabe nessa folha
What it means
Thrown by slice when the computed sprite grid produces zero cells for the loaded sheet — i.e. cols/rows/cell size, margin and spacing do not fit within the image dimensions. grid_cells() returned an empty list, so there is nothing to slice.
Solutions
- Verify cell_w*cols + spacing*(cols-1) + 2*margin <= sheet width, and the same for height.
- Set cols/rows/cell_w/cell_h to 0 if the tool supports auto-derivation from the sheet size.
- Log sheet.width()/height() and the grid values before slicing to spot the mismatch.
- Reject or auto-correct oversized grid configs in the UI before calling run().
Example fix
// before
let grid = Grid { cols: 10, rows: 10, cell_w: 512, cell_h: 512, margin: 0, spacing: 0 };
// after
// for a 1024x1024 sheet this fits; validate first:
assert!(opts.cell_w * opts.cols <= sheet_width && opts.cell_h * opts.rows <= sheet_height); Defensive patterns
Strategy: validation
Validate before calling
fn grid_fits(sheet_w: u32, sheet_h: u32, g: &Grid) -> bool {
let gw = g.margin * 2 + g.cell_w * g.cols + g.spacing * g.cols.saturating_sub(1);
let gh = g.margin * 2 + g.cell_h * g.rows + g.spacing * g.rows.saturating_sub(1);
gw <= sheet_w && gh <= sheet_h && g.cols > 0 && g.rows > 0 && g.cell_w > 0 && g.cell_h > 0
} Try / catch
match image_sprite::run(&opts, &progress) {
Err(e) if e.to_string().contains("a grade não cabe") => {
eprintln!("ajuste cols/rows/cell_w/cell_h para o tamanho da folha");
}
other => other?,
} Prevention
- Compute the grid math against real image dimensions before slicing.
- Reuse per-sheet saved options, not global ones.
- Clamp cell sizes to sheet dimensions in the UI.
- Log sheet.width()/height() alongside grid params on failure.
When it happens
Trigger: Calling run() with mode "slice" where cell_w/cell_h plus margins and spacing exceed sheet width/height, or cols/rows are zero, or the image is smaller than one cell.
Common situations: Manual grid config mistakes (values in the wrong unit, e.g. pixels vs percentage); reusing options from a different sheet; spacing/margin set too large for a small sheet.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- escolha o spritesheet
- escolha os quadros
- MB não cabem s de vídeo — aumente o alvo ou encurte o clipe
- a API oficial so aceita URLs publicas (https://…) para os…
- a capa não é PNG, JPEG, GIF ou BMP
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/9012157a6b66cc19.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/image_sprite.rs:358
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())
.unwrap_or_else(|| "quadro".into())
} else {
super::sanitize_name(&opts.name)
};
let dir = out_dir(
opts,
&input
.parent()
.map(|p| p.join(format!("{}-quadros", stem)))
.unwrap_or_default(),
);
std::fs::create_dir_all(&dir)?;View on GitHub (pinned to 8600b91f42)