run-llama/liteparse · error · std::io::Error
invalid zero-sized RGB image
Error message
invalid zero-sized RGB image: {width}x{height} What it means
rgb_image in the oar OCR module builds an image::RgbImage from a raw RGB byte buffer plus declared width/height. Before doing so it validates the dimensions: if either width or height is 0 the image is meaningless, so it rejects the call with this InvalidInput error. This guards against empty OCR buffers reaching the image constructor.
Solutions
- Check the source image's dimensions before OCR and skip/error early if width or height is 0.
- Re-encode or re-decode the image to recover real dimensions; if the file is corrupt, replace it.
- Fix the upstream producer (e.g. OCR HTTP server or renderer) that reports zero-sized images.
Example fix
// before: blind OCR call with unverified dimensions
ocr.recognize_sync(&buf, width, height)?;
// after: validate first
if width == 0 || height == 0 {
return Err(anyhow!("skipping OCR: image has zero extent"));
}
ocr.recognize_sync(&buf, width, height)?; Defensive patterns
Strategy: validation
Validate before calling
// Rust: reject zero-dimension images before OCR
fn dims_ok(width: u32, height: u32) -> bool {
width > 0 && height > 0
} Type guard
fn non_zero_dims(w: u32, h: u32) -> Option<(u32, u32)> {
(w > 0 && h > 0).then_some((w, h))
} Prevention
- Validate decoded image dimensions before invoking OCR
- Skip OCR for zero-extent images rather than passing them through
- Check upstream renderers/OCR servers for zero-size metadata bugs
When it happens
Trigger: Calling the OCR recognize path (recognize_sync) with an image buffer whose reported width or height is 0; also exercised by the rejects_non_rgb_buffers test path. Any caller that passes dimensions from a decoded image whose header claims zero extent triggers it.
Common situations: Corrupt or truncated image files whose decoded dimensions come back as 0; OCR server responses that report zero-size image metadata; passing an uninitialized/placeholder buffer to the OCR API.
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
- RGB image dimensions overflow
- invalid RGB buffer length for
- failed to construct RGB image from
- no data on stdin (input `-` expects a document piped in…
- no data on stdin (input `-` expects a document piped in…
AI-assisted analysis of run-llama/liteparse@22d2dd8cd7 (2026-09-08).
Data as JSON: /api/errors/a75f3588140491b5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/liteparse/src/ocr/oar.rs:260
}
static LANGUAGE_IGNORED_WARNING: Once = Once::new();
/// Warn once per process that this backend ignores `OcrOptions::language`.
fn warn_language_ignored_once(language: &str) {
if language.is_empty() {
return;
}
LANGUAGE_IGNORED_WARNING.call_once(|| {
eprintln!(
"[oar-ocr] ignoring OcrOptions::language ({language:?}); recognition language is fixed by the model and character dictionary"
);
});
}
fn rgb_image(image_data: &[u8], width: u32, height: u32) -> Result<image::RgbImage, io::Error> {
if width == 0 || height == 0 {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
format!("invalid zero-sized RGB image: {width}x{height}"),
));
}
let expected_len = (width as usize)
.checked_mul(height as usize)
.and_then(|pixels| pixels.checked_mul(3))
.ok_or_else(|| {
io::Error::new(
io::ErrorKind::InvalidInput,
format!("RGB image dimensions overflow: {width}x{height}"),
)
})?;
if image_data.len() != expected_len {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,View on GitHub (pinned to 22d2dd8cd7)