feat: residue and a solid background stop a ready sheet before payment
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Failing after 4m10s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Has been skipped
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Failing after 4m10s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Has been skipped
Dropstar's items 2 and 3 (2026-10-21): both were warnings the customer could pay past; now one dot is enough to stop the order. - every pixel is read (images in strips at 1:1, large PNGs while they stream, PDFs rendered in strips at about 0,2 mm): the old check shrank the image first and could miss a small dot, or sampled every n-th pixel - a residue is ink under 2 mm on both sides, measured from where the ink starts and ends in each cell: the same dot gets the same verdict wherever it falls on the grid, from 0,5 to 4 mm (his acceptance test) - a solid background is under 1,5 % of transparent pixels; a JPG sheet always has one - the sheet says how many dots there are, circles them on the preview, and asks to erase them and send again; the order waits for the check to end - the page no longer offers JPG for a ready sheet Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,12 @@ Z.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){I.click();e.pr
|
||||
if(ev==='drop') sel([...e.dataTransfer.files]);
|
||||
}));
|
||||
I.addEventListener('change',()=>sel([...I.files]));
|
||||
// A sheet with residue gets its preview circled where the dots are.
|
||||
async function marcaResiduos(x){
|
||||
if(!(x.an && x.an.residuos && !x.an.fundoChapado && x.previewSrc && x.an.pontos?.length)) return;
|
||||
const marcada=await previaMarcada(x.previewSrc, x.an.pontos);
|
||||
if(folhas.includes(x)){ x.previewSrc=marcada; pintaFolha(); }
|
||||
}
|
||||
function sel(fs){
|
||||
if(!fs.length) return;
|
||||
// Pixels cannot tell a loose artwork from a finished sheet, so the customer
|
||||
@@ -64,6 +70,8 @@ function sel(fs){
|
||||
// stream into a small copy: the preview, and the sheet check.
|
||||
x.an={dpi:md.dpiFolha, grande:true, artes:0, residuos:0, encostadas:0,
|
||||
fundoChapado:false, aproveitamento:0, alturaCm:md.alt, fonteDpi:'arquivo'};
|
||||
// A JPG has no transparency: its background is always solid.
|
||||
if(/\.jpe?g$/i.test(x.f.name)){ x.an={...x.an, grande:false, fundoChapado:true, residuos:0, pontos:[]}; }
|
||||
if(!/\.png$/i.test(x.f.name)){ x.pct=null; pintaFolha(); return; }
|
||||
x.pct=60; x.leitura={inicio:Date.now(), p:0}; pintaFolha();
|
||||
let mostrado=0;
|
||||
@@ -71,36 +79,41 @@ function sel(fs){
|
||||
const pct=60+Math.floor(p*38);
|
||||
x.leitura.p=p;
|
||||
if(pct-mostrado>=1){ mostrado=pct; x.pct=pct; pintaProgressoFolha(x); }
|
||||
}).then(cv=>{
|
||||
if(cv && folhas.includes(x)){
|
||||
}, md.larg).then(lido=>{
|
||||
if(lido && folhas.includes(x)){
|
||||
const cv=lido.cv;
|
||||
x.previewSrc=cv.toDataURL('image/webp',0.85); x.miniSrc=miniatura(cv); x.fotoSrc=miniatura(cv,480,720);
|
||||
try{
|
||||
const an=analisarFolha(cv, md.larg);
|
||||
const an=analisarMapa(lido.mapa);
|
||||
x.an={...an, dpi:md.dpiFolha, fonteDpi:'arquivo', grande:false};
|
||||
}catch(e){}
|
||||
}
|
||||
}).catch(()=>{}).finally(()=>{ x.pct=null; pintaFolha(); });
|
||||
}).catch(()=>{}).finally(()=>{ x.pct=null; pintaFolha(); marcaResiduos(x); });
|
||||
}else if(md && RENDERIZA.test(x.f.name)){
|
||||
carregarImagem(x.f).then(img=>{
|
||||
if(img){ x.previewSrc=img.src; x.miniSrc=miniatura(img); x.fotoSrc=miniatura(img,480,720); try{ x.an=analisarFolha(img, md.larg); if(x.an) x.an.fonteDpi='arquivo'; }
|
||||
catch(e){} }
|
||||
x.pct=null; pintaFolha();
|
||||
carregarImagem(x.f).then(async img=>{
|
||||
if(img){
|
||||
x.previewSrc=img.src; x.miniSrc=miniatura(img); x.fotoSrc=miniatura(img,480,720);
|
||||
x.pct=80; pintaFolha();
|
||||
try{ x.an={...analisarMapa(await mapaDaImagem(img, md.larg)), fonteDpi:'arquivo'}; }catch(e){}
|
||||
}
|
||||
x.pct=null; pintaFolha(); marcaResiduos(x);
|
||||
});
|
||||
}else if(md && /\.pdf$/i.test(x.f.name) && x.f.size>GRANDE_BYTES){
|
||||
x.semAnalise='PDF grande: a resolução das imagens de dentro é conferida pela equipe';
|
||||
x.pct=null; pintaFolha();
|
||||
}else if(md && /\.pdf$/i.test(x.f.name)){
|
||||
x.pct=70; pintaFolha();
|
||||
rasterizarPdf(x.f, md.larg, md.alt).then(r=>{
|
||||
rasterizarPdf(x.f, md.larg, md.alt, true).then(r=>{
|
||||
if(r && r.erro){
|
||||
x.semAnalise = r.erro + (r.semWorker
|
||||
? ' · este navegador não deixa o leitor rodar em segundo plano'
|
||||
: '');
|
||||
}
|
||||
if(r && r.tela){
|
||||
if(r && r.tela && r.mapa){
|
||||
x.miniSrc=miniatura(r.tela); x.fotoSrc=miniatura(r.tela,480,720);
|
||||
x.previewSrc=r.tela.toDataURL('image/webp',0.85);
|
||||
try{
|
||||
x.an=analisarFolha(r.tela, md.larg);
|
||||
x.an=analisarMapa(r.mapa);
|
||||
// vetor puro não tem resolução · nota máxima, e está certo
|
||||
x.an.dpi = r.dpi==null ? DPI_AVISA : r.dpi;
|
||||
x.an.vetor = r.dpi==null;
|
||||
@@ -108,7 +121,7 @@ function sel(fs){
|
||||
x.an.res = r.res || null;
|
||||
}catch(e){}
|
||||
}
|
||||
x.pct=null; pintaFolha();
|
||||
x.pct=null; pintaFolha(); marcaResiduos(x);
|
||||
});
|
||||
}else{ x.pct=null; pintaFolha(); }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user