{"record":{"id":"52ad29b852cc9469","repo":"sxyazi/yazi","slug":"image-is-empty","errorCode":null,"errorMessage":"image is empty","messagePattern":"image is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-adapter/src/drivers/sixel.rs","lineNumber":52,"sourceCode":"\n\tpub(super) fn image_erase(area: Rect) -> Result<()> {\n\t\tlet s = \" \".repeat(area.width as usize);\n\t\tEmulator::move_lock((0, 0), |w| {\n\t\t\tif let Some(c) = THEME.app.overall.get().bg {\n\t\t\t\twrite!(w, \"{}\", SetBg(c))?;\n\t\t\t}\n\t\t\tfor y in area.top()..area.bottom() {\n\t\t\t\twrite!(w, \"{}\", MoveTo(area.x, y))?;\n\t\t\t\twrite!(w, \"{s}\")?;\n\t\t\t}\n\t\t\tOk(write!(w, \"{ResetAttrs}\")?)\n\t\t})\n\t}\n\n\tasync fn encode(img: DynamicImage) -> Result<Vec<u8>> {\n\t\tlet alpha = img.color().has_alpha();\n\t\tif img.width() == 0 || img.height() == 0 {\n\t\t\tbail!(\"image is empty\");\n\t\t}\n\n\t\tlet (qo, img) = tokio::task::spawn_blocking(move || match &img {\n\t\t\tDynamicImage::ImageRgb8(rgb) => Self::quantify(rgb, false).map(|q| (q, img)),\n\t\t\t_ => Self::quantify(&img.to_rgb8(), alpha).map(|q| (q, img)),\n\t\t})\n\t\t.await??;\n\n\t\ttokio::task::spawn_blocking(move || {\n\t\t\tlet mut buf = vec![];\n\t\t\twrite!(buf, \"{START}P9;1q\\\"1;1;{};{}\", img.width(), img.height())?;\n\n\t\t\t// Palette\n\t\t\tfor (i, c) in qo.palette.iter().enumerate() {\n\t\t\t\twrite!(\n\t\t\t\t\tbuf,\n\t\t\t\t\t\"#{};2;{};{};{}\",\n\t\t\t\t\ti + alpha as usize,","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-adapter/src/drivers/sixel.rs#L34-L70","documentation":"The image passed into sixel encoding has a zero width or height, so there are no pixels to encode. This is a precondition guard before spawning the blocking encoder; the faulting input is the decoded `DynamicImage` (e.g. a truncated or corrupt image that still decoded to an empty frame).","triggerScenarios":"Thrown at yazi-adapter/src/drivers/sixel.rs:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the source image for corruption or zero dimensions before previewing.","Skip sixel preview for empty images and let a text/other previewer take over.","Validate image dimensions after decoding and before dispatching to an adapter."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}