feat: pack large artworks in Artes avulsas from a streamed copy
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Failing after 2m36s
Build and deploy / Secret scan and release gate (push) Successful in 8s
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 2m36s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Has been skipped
Artes avulsas decoded every file whole, and the packing decoded each one again on every repaint, so a large artwork failed to load. A PNG over 150 MB is now measured from its header (pixel size, so DPI and grade stay exact) and packed from a 1200-pixel copy read as a stream, with progress on its card; every artwork's image is loaded once and reused by the packing. A large JPG or WebP asks for a PNG, and the grade card no longer calls a file unreadable while it is still being read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -136,6 +136,24 @@ function sel(fs){
|
||||
Promise.all(novos.map(medir)).then(pintaArtes);
|
||||
}
|
||||
function medir(a){
|
||||
// A large artwork is measured from its header and packed from a small copy
|
||||
// read as a stream (previaPngGrande); the file itself is never decoded.
|
||||
if(a.f.size>GRANDE_BYTES){
|
||||
return dimensoesImagem(a.f).then(async d=>{
|
||||
if(!d || !(d.w>0) || !(d.h>0)){ a.decodeError=true; return a; }
|
||||
a.px=d.w; a.py=d.h; a.prop=d.h/d.w; a.grande=true;
|
||||
if(!/\.png$/i.test(a.f.name)){ a.decodeError='grande'; return a; }
|
||||
a.lendo=0; pintaArtes();
|
||||
let mostrado=0;
|
||||
const cv=await previaPngGrande(a.f, 1200, p=>{
|
||||
const pct=Math.floor(p*100);
|
||||
if(pct-mostrado>=1){ mostrado=pct; a.lendo=pct; pintaProgressoArte(a); }
|
||||
}).catch(()=>null);
|
||||
a.lendo=null;
|
||||
if(cv && artes.includes(a)) a.src=cv.toDataURL('image/webp',0.9); else if(!cv) a.decodeError=true;
|
||||
return a;
|
||||
}).catch(()=>{ a.decodeError=true; return a; });
|
||||
}
|
||||
return carregarImagem(a.f).then(img=>{
|
||||
if(img){ a.prop=img.height/img.width; a.px=img.width; a.py=img.height; a.src=img.src; }
|
||||
else a.decodeError=true;
|
||||
|
||||
Reference in New Issue
Block a user