{"record":{"id":"bbed6de6672fb44a","repo":"pbakaus/impeccable","slug":"comp-spec-e","errorCode":null,"errorMessage":"comp-spec: {e}\n","messagePattern":"comp-spec: (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/comp-verbs/src/comp_spec.rs","lineNumber":862,"sourceCode":"            r::crop(&comp, px(\"x\"), px(\"y\"), px(\"w\"), px(\"h\"))\n        };\n        let scale = util::parse_f64(arg_or(argv, \"scale\", \"1\"), 1.0);\n        if scale > 1.0 {\n            c = r::resize(&c, c.width as f64 * scale, c.height as f64 * scale);\n        }\n        let default_out = join_path(&join_path(BUILD_DIR, \"crops\"), &format!(\"{id}.png\"));\n        let out = arg_or(argv, \"out\", &default_out).to_string();\n        let out_path = resolve(io, &out);\n        if let Some(parent) = out_path.parent() {\n            let _ = std::fs::create_dir_all(parent);\n        }\n        let text = vec![(\"impeccable:crop-of\".to_string(), format!(\"{comp_file}#{id}\"))];\n        match png_io::encode_png(&c, &text) {\n            Ok(bytes) => {\n                let _ = std::fs::write(&out_path, bytes);\n            }\n            Err(e) => {\n                io.err(&format!(\"comp-spec: {e}\\n\"));\n                return 1;\n            }\n        }\n        io.out(&format!(\"CROP {out} ({}x{}) region {id} of {comp_file}. Reference only: regenerate the plate from it, never ship it.\\n\", c.width, c.height));\n        return 0;\n    }\n\n    let comp_path = arg(argv, \"comp\");\n    let Some(comp_path) = comp_path else {\n        io.err(\"usage: comp-spec.mjs --comp <png> (--grid | --regions <json> | --auto) [--spec out.json]\\n       comp-spec.mjs --print | --crop <id> [--out file] [--scale n] | --plate-prompt <id>\\n\");\n        return 1;\n    };\n    let comp = match png_io::load_raster(&resolve(io, comp_path)) {\n        Ok((d, _)) => d.image,\n        Err(e) => {\n            io.err(&format!(\"comp-spec: cannot read {comp_path}: {e}\\n\"));\n            return 1;\n        }","sourceCodeStart":844,"sourceCodeEnd":880,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/comp-verbs/src/comp_spec.rs#L844-L880","documentation":"After cropping (and optionally scaling) the region, comp-spec encodes the result as PNG with embedded provenance text via png_io::encode_png. This error surfaces any encoder failure, aborting the crop before the output file is written.","triggerScenarios":"png_io::encode_png fails while encoding the cropped region image — e.g. an internal raster/encoder error such as an unsupported pixel format or an encoder panic converted to an error. This is rare and mostly indicates a problem with the source raster rather than user input.","commonSituations":"Corrupt or exotic source PNGs that decode into an unexpected pixel layout; extremely large crops combined with --scale producing allocations/encoder limits; engine build issues with the PNG encoder.","solutions":["Re-encode or re-export the source comp PNG with a standard tool (e.g. ImageMagick `convert comp.png comp.png`) and regenerate the spec.","Retry with a smaller crop/scale (lower --scale value) to rule out size-related encoder failures.","Rebuild or reinstall the engine binary if the failure is reproducible across inputs.","Check the underlying error text after `comp-spec:` for the specific encoder cause."],"exampleFix":"// before\ncomp-spec --crop art --scale 64   // enormous upscaled crop\n// after\ncomp-spec --crop art --scale 2","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"const r = spawnSync('impeccable', ['comp-spec', '--crop', id, '--out', out]);\nif (r.status !== 0) {\n  const msg = r.stderr.toString();\n  if (msg.startsWith('comp-spec:') && !msg.includes('no spec') && !msg.includes('no region')) {\n    // encoder-side failure: fall back to re-exporting the source PNG and retry once\n  }\n  throw new Error(msg.trim());\n}","preventionTips":["Use standard 8-bit RGBA PNGs as comp sources.","Keep --scale values modest (1-4x) rather than extreme upscales.","Re-export source images with a standard encoder if crops fail reproducibly.","Confirm the output directory is writable; comp-spec ignores fs::write errors by design."],"tags":["cli","png","encoding"],"backgroundTag":"file-write-failed","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}