tonhowtf/omniget · error
escolha pelo menos uma imagem
Error message
escolha pelo menos uma imagem
What it means
Input validation at the top of images_to_pdf(): the function requires at least one image path in inputs; with an empty slice it errors immediately before computing quality defaults or converting any JPEG. It fires when the images-to-PDF operation is invoked with no input images selected.
Solutions
- Pass at least one image path in inputs.
- Guard the action in the UI until at least one image is selected.
- If files were filtered out, inform the user why instead of calling with an empty vec.
Example fix
// before
build_pdf_from_images(&[], out, quality, progress)
// after
if !images.is_empty() { build_pdf_from_images(&images, out, quality, progress) } else { /* surface selection error */ } Defensive patterns
Strategy: validation
Validate before calling
if inputs.is_empty() {
return Err("select at least one image");
}
for p in inputs {
if !std::path::Path::new(p).is_file() {
return Err(format!("not a file: {}", p));
}
} Try / catch
if inputs.is_empty() {
eprintln!("no images selected");
} else {
match images_to_pdf(&inputs, output, quality, &progress) {
Ok(out) => use(out),
Err(e) => eprintln!("conversion failed: {e}"),
}
} Prevention
- Guard the convert action until at least one image is picked.
- Report filtered-out files to the user instead of silently dropping them.
- Keep the raw selection count visible in the UI.
When it happens
Trigger: Calling the internal img->PDF builder with inputs: &[] — e.g. the caller filtered out all non-image files, or the UI submitted the conversion with no files selected.
Common situations: File picker returning empty selection; extension filter removing everything (only .png/.jpg allowed but user picked .webp which was filtered elsewhere); drag-drop with no files.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/0bc06ccb71762a39.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/pdf.rs:1024
None
};
Ok(TextResult {
text,
output,
pages: pages.len(),
})
}
// ── Imagens → PDF ──────────────────────────────────────────────────────
pub fn images_to_pdf(
inputs: &[String],
output: &str,
quality: u8,
progress: &super::ProgressFn,
) -> anyhow::Result<PdfOut> {
if inputs.is_empty() {
return Err(anyhow!("escolha pelo menos uma imagem"));
}
let quality = if quality == 0 { 90 } else { quality };
let mut jpegs = Vec::with_capacity(inputs.len());
let n = inputs.len() as u64;
for (i, input) in inputs.iter().enumerate() {
report(progress, "progress", i as u64, Some(n), Some(input.clone()));
let data = std::fs::read(input).map_err(|e| anyhow!("nao leu {}: {}", input, e))?;
if jpeg_pdf::is_jpeg(&data) {
jpegs.push(data);
} else {
let img = image::load_from_memory(&data)
.map_err(|e| anyhow!("{}: {}", input, e))?
.to_rgb8();
jpegs.push(encode(&img, "jpg", quality)?);
}
}
let pdf = jpeg_pdf::build_pdf(&jpegs)?;
let out = unique(PathBuf::from(output.trim()));View on GitHub (pinned to 8600b91f42)