tonhowtf/omniget · error
nenhuma imagem
Error message
nenhuma imagem
What it means
build_pdf assembles an in-memory PDF from a slice of raw JPEG buffers, one page per image. With an empty input it has nothing to render, so it fails fast with "nenhuma imagem" (no images). It guards against generating a meaningless empty PDF.
Solutions
- Check images.len() > 0 before calling build_pdf and surface a friendly message to the user instead
- Fix the upstream collection step (search/download) so at least one image is produced
- Relax over-aggressive filtering that removes every candidate image before building
Example fix
// before
let images: Vec<Vec<u8>> = collect().into_iter().filter(valid).collect(); // empty
let pdf = build_pdf(&images)?; // Err: nenhuma imagem
// after
if images.is_empty() {
bail!("nenhuma imagem para converter"); // handle before calling
}
let pdf = build_pdf(&images)?; Defensive patterns
Strategy: validation
Validate before calling
if images.is_empty() {
return Err("nenhuma imagem para gerar o PDF");
} Type guard
fn has_images(images: &[Vec<u8>]) -> bool {
!images.is_empty()
} Try / catch
match build_pdf(&images) {
Err(e) if e.to_string() == "nenhuma imagem" => show_empty_selection_warning(),
r => r,
} Prevention
- Disable the PDF export action when the image list is empty
- Check the upstream download/search step for zero results before building
- Log how many candidate images survive filtering so silent empty sets are visible
When it happens
Trigger: Calling build_pdf(&[]) — typically when an upstream collection step produced no images: a search/download returned zero results, or all files were filtered out as non-JPEG before reaching the builder.
Common situations: User confirms a PDF export with an empty selection; downloads all failed so the images vector ended up empty; caller filtered out corrupt/non-JPEG files leaving zero valid entries.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- informe um appid, um link da loja ou marque a biblioteca…
- escolha ao menos uma imagem
- nenhuma pagina selecionada
- não achei a assinatura %PDF- — o arquivo não parece um PDF
- escolha o PDF
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/9b851f41ca3f1c52.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/jpeg_pdf.rs:58
return Ok(JpegInfo {
width,
height,
components,
});
}
i += 2 + len;
}
Err(anyhow!("JPEG sem cabecalho SOF"))
}
pub fn is_jpeg(data: &[u8]) -> bool {
data.len() > 3 && data[0] == 0xFF && data[1] == 0xD8 && data[2] == 0xFF
}
/// Monta o PDF em memória. Página no tamanho da imagem em pontos (72 dpi).
pub fn build_pdf(images: &[Vec<u8>]) -> anyhow::Result<Vec<u8>> {
if images.is_empty() {
return Err(anyhow!("nenhuma imagem"));
}
let mut out: Vec<u8> = Vec::new();
let mut offsets: Vec<usize> = Vec::new();
out.extend_from_slice(b"%PDF-1.4\n%\xE2\xE3\xCF\xD3\n");
// objetos: 1 catalog, 2 pages, depois por imagem: page, xobject, content
let n_pages = images.len();
let obj_page = |i: usize| 3 + i * 3;
let obj_img = |i: usize| 4 + i * 3;
let obj_content = |i: usize| 5 + i * 3;
let total_objs = 2 + n_pages * 3;
let push_obj = |out: &mut Vec<u8>, offsets: &mut Vec<usize>, body: &[u8]| {
offsets.push(out.len());
out.extend_from_slice(body);
};
push_obj(View on GitHub (pinned to 8600b91f42)