perf: a ready sheet is decoded once for its check, with the progress shown
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 3m23s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m8s

Drawn from the <img>, a large sheet was decoded again for each strip the
residue check reads. Decoded once into an ImageBitmap and reused for the
thumbnails, the check of a 57 x 50 cm sheet at 300 DPI drops from 4,7 s to
1,4 s, and the bar moves while it runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-22 18:06:03 -03:00
parent 88181b755d
commit 56e5462647
2 changed files with 13 additions and 3 deletions

View File

@@ -92,9 +92,17 @@ function sel(fs){
}else if(md && RENDERIZA.test(x.f.name)){
carregarImagem(x.f).then(async img=>{
if(img){
x.previewSrc=img.src; x.miniSrc=miniatura(img); x.fotoSrc=miniatura(img,480,720);
// Decoded once and kept: drawn from the <img>, a large sheet is
// decoded again for each strip the check reads.
const fonte=await createImageBitmap(img).catch(()=>img);
x.previewSrc=img.src; x.miniSrc=miniatura(fonte); x.fotoSrc=miniatura(fonte,480,720);
x.pct=80; pintaFolha();
try{ x.an={...analisarMapa(await mapaDaImagem(img, md.larg)), fonteDpi:'arquivo'}; }catch(e){}
let mostrado=80;
try{ x.an={...analisarMapa(await mapaDaImagem(fonte, md.larg, p=>{
const pct=80+Math.floor(p*19);
if(pct>mostrado){ mostrado=pct; x.pct=pct; pintaProgressoFolha(x); }
})), fonteDpi:'arquivo'}; }catch(e){}
if(fonte.close) fonte.close();
}
x.pct=null; pintaFolha(); marcaResiduos(x);
});