mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-15 23:56:29 +03:00
Read WebP/JPEG comps through a sibling PNG cache instead of forcing PNG
comp-spec, comp-diff, build-phase, font-match, and generate-image now decode any comp raster via loadRaster(), converting non-PNG input to <file>.png next to the source. Sessions used to hit 'not a PNG' and rewrite the .webp in place with PNG bytes, which broke transcript replay (a later step rewrites the comp beyond the cut) and left a mislabeled file. AI-assisted (Claude Code).
This commit is contained in:
@@ -207,7 +207,7 @@ const plateId = arg('plate');
|
||||
let plateCtx = null;
|
||||
if (plateId) {
|
||||
const { loadSpec, platePrompt, plateReference, SPEC_PATH } = await import('./comp-spec.mjs');
|
||||
const { decodePng, encodePng } = await import('./lib/png.mjs');
|
||||
const { decodePng, encodePng, loadRaster } = await import('./lib/png.mjs');
|
||||
const { crop, resize } = await import('./lib/raster.mjs');
|
||||
const specPath = arg('spec', SPEC_PATH);
|
||||
const spec = loadSpec(specPath);
|
||||
@@ -216,7 +216,7 @@ if (plateId) {
|
||||
if (!region) { console.error(`generate-image: no region ${plateId} in ${specPath}; ids: ${spec.regions.map((r) => r.id).join(', ')}`); process.exit(1); }
|
||||
if (region.medium !== 'raster') { console.error(`generate-image: region ${plateId} is ${region.medium}, not a plate; set its kind to plate|image|texture in the regions file`); process.exit(1); }
|
||||
let comp;
|
||||
try { comp = decodePng(fs.readFileSync(spec.comp)); } catch (e) { console.error(`generate-image: cannot read comp ${spec.comp}: ${e.message}`); process.exit(1); }
|
||||
try { comp = loadRaster(spec.comp).image; } catch (e) { console.error(`generate-image: cannot read comp ${spec.comp}: ${e.message}`); process.exit(1); }
|
||||
const ref = plateReference(comp, spec, region);
|
||||
const refPath = path.join(path.dirname(specPath), 'crops', `${region.id}.png`);
|
||||
fs.mkdirSync(path.dirname(refPath), { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user