mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-11 21:57:14 +03:00
Address the Bugbot and Copilot findings on #599
- keyChroma re-encodes with the PNG's tEXt chunks intact (the embedded prompt survived generation but not keying)
- organic-clip-path counts relative curve commands too (path data letters are only commands, so the match is case-insensitive)
- buried-raster normalizes percentage alphas (parseFloat('80%') read as 80) and reads 4- and 8-digit hex alpha instead of treating #rrggbbaa as opaque
- the extension-injected-node skip in checkQuality runs before any finding is pushed (a low-opacity injected raster was recorded, then returned by the skip)
- fake-mode plates carry impeccable:fake tEXt and the plates gate's crop-identity refusal skips them (fake mode IS the crop by design; the refusal is for models shipping the comp's pixels as artwork)
Findings by cursor[bot] and Copilot on PR #599; detector engines rebuilt (build:browser, build:extension).
AI-assisted (Claude Code).
This commit is contained in:
@@ -299,7 +299,12 @@ export function gatePlates(state, { specPath = SPEC_PATH } = {}) {
|
||||
// upscaled past the size floor: the comp's grain, its neighbours'
|
||||
// edges, and its resolution ship as the artwork. Crops are never
|
||||
// plates; the crop is the reference the plate is generated from.
|
||||
if (!isTexture) {
|
||||
// A fake-mode plate (offline pipelines, eval fixtures) IS the crop by
|
||||
// design and says so in its tEXt; the identity refusal is for models
|
||||
// shipping the comp's pixels as artwork, not for the deterministic
|
||||
// stand-in.
|
||||
const isFake = img.text && img.text['impeccable:fake'] === '1';
|
||||
if (!isTexture && !isFake) {
|
||||
const raw = crop(comp, r.px.x, r.px.y, r.px.w, r.px.h);
|
||||
const same = structureScore(raw, resize(img, raw.width, raw.height));
|
||||
if (same >= 0.95) reasons.push(`plate ${file} is the comp crop of region ${r.id} (structure ${(same * 100).toFixed(0)}% against the raw region, a resample of the same pixels): a crop of the comp is never a plate; generate the plate from the crop as reference (generate-image.mjs --plate ${r.id})`);
|
||||
|
||||
@@ -248,7 +248,7 @@ if (plateId) {
|
||||
plateCtx = { spec, specPath, region, ref, refPath, out, size, prompt, comp, encodePng, resize, chroma: wantsChroma ? chromaColor : null };
|
||||
if (process.env.IMPECCABLE_IMAGE_GEN_FAKE) {
|
||||
const up = resize(ref, ref.width * 2, ref.height * 2);
|
||||
fs.writeFileSync(out, encodePng(up, { text: { 'impeccable:prompt': prompt } }));
|
||||
fs.writeFileSync(out, encodePng(up, { text: { 'impeccable:prompt': prompt, 'impeccable:fake': '1' } }));
|
||||
fs.writeFileSync(`${out}.json`, JSON.stringify({ prompt, createdAt: new Date().toISOString(), tool: 'generate-image.mjs', model: 'fake', plate: region.id, refs: [refPath] }, null, 2));
|
||||
console.log(`PLATE: ${out} (${up.width}x${up.height}, fake 2x crop of region ${region.id}, $0.00, no API call)`);
|
||||
process.exit(0);
|
||||
@@ -296,7 +296,8 @@ async function keyChroma(file, keyHex) {
|
||||
const m = (r + b) / 2; img.data[i + 1] = Math.round(g * a + m * (1 - a));
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(file, encodePng(img));
|
||||
// keep the tEXt chunks (the embedded prompt written before keying)
|
||||
fs.writeFileSync(file, encodePng(img, { text: img.text && Object.keys(img.text).length ? img.text : null }));
|
||||
return keyed / (img.data.length / 4);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user