feat: a ready sheet prints at its real size, centred on the film, with the customer's confirmation (Marcus, 2026-12-02)
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 7m55s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m43s

Replaces 7111995 (only 57,0 cm entered; a whole order of 56,5-56,9 cm
sheets was refused, DTF-WEB-2C). Marcus's rules, for Arquivo por metro,
Premium (57 cm) and UV (27 cm):
1. A known width up to the film (PNG recording 200 DPI or more, or a PDF
   page) enters at its real size, centred, billed by its real height.
2. Narrower: his warning before the cart, confirmation required
   (Imprimir no tamanho real / Enviar outro arquivo); recorded in the
   Prumo report ("cliente confirmou folha de 35,8 cm no tamanho real") and
   shown in the cart and payment summaries.
3. Wider than the film: refused with his message.
4. Unknown width: taken as the film's, DPI from the pixels; 200 or more
   with a confirmation, under 200 refused with the artes avulsas hint.
Within 0,1 cm of the film counts as the film. The server checks it all
again at checkout (sheet_width_issue, centred placement, size_confirmed).

Also ops.stretched_sheets: the ready-sheet orders since 16/10 laid out
wider than their real width (number, real width, factor), for Marcus.
Contract: output/revisao/contrato-folha-real.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-02 09:51:38 -03:00
parent 7af6c9797d
commit 41126a42fd
22 changed files with 634 additions and 153 deletions

View File

@@ -360,17 +360,22 @@ function medirFolha(file){
if(/\.png$/.test(nome)){
dimensoesImagem(file).then(async d=>{
if(!d || !(d.w>0) || !(d.h>0)) return res({rejected:true,reason:'Não foi possível ler as dimensões do PNG. Exporte novamente.'});
// Folha têxtil de 57 cm: se o PNG diz o DPI real, a largura tem de ser 57.
const exata=LARGURA_EXATA[modo];
if(exata!=null){
const dpi=await dpiSalvoPng(file);
if(dpi>=DPI_TAMANHO_REAL){
const cm=d.w/dpi*2.54;
if(Math.abs(cm-exata)>LARGURA_TOLERANCIA_CM) return res({larguraErrada:{cm, dpi}});
}
const L=larguraFilme(), tol=LARGURA_TOLERANCIA_CM, dpi=await dpiSalvoPng(file);
let measure;
if(dpi>=DPI_TAMANHO_REAL){
// A largura real vem do pHYs; até 0,1 cm além do filme conta como o filme.
const cm=d.w/dpi*2.54;
if(cm>L+tol) return res({largaDemais:{cm}});
// Até 0,1 cm além do filme é o filme: a folha nunca passa da largura dele.
measure={larg:Math.min(cm,L), alt:+(d.h/dpi*2.54).toFixed(1), fonte:'dimensões do arquivo',
dpiFolha:dpi, px:d.w};
if(cm<L-tol) measure.confirmar='estreita';
}else{
// Sem DPI confiável a folha vale o filme inteiro; o DPI sai dos pixels.
measure={larg:L, alt:+(d.h/d.w*L).toFixed(1), fonte:'dimensões do arquivo',
dpiFolha:Math.round(d.w/(L/2.54)), px:d.w, larguraDesconhecida:true};
if(measure.dpiFolha>=DPI_MINIMO_FOLHA) measure.confirmar='desconhecida';
}
const L=larguraFilme(), measure={larg:L,alt:+(d.h/d.w*L).toFixed(1),
fonte:'dimensões do arquivo',dpiFolha:Math.round(d.w/(L/2.54)),px:d.w};
if(d.h>32767 || file.size>GRANDE_BYTES) return res({...measure,grande:true,tall:d.h>32767});
// A PNG the phone cannot open whole (out of memory, a 57 MB sheet on
// 26/11) is read in bands like a large one, never sent to the manual
@@ -382,21 +387,25 @@ function medirFolha(file){
if(RENDERIZA.test(nome) && file.size>GRANDE_BYTES){
dimensoesImagem(file).then(d=>{
if(!d || !(d.w>0) || !(d.h>0)) return res(null);
const L=larguraFilme();
res({larg:L, alt:+(d.h/d.w*L).toFixed(1), fonte:'dimensões do arquivo',
dpiFolha:Math.round(d.w/(L/2.54)), px:d.w, grande:true});
const L=larguraFilme(), dpiFolha=Math.round(d.w/(L/2.54));
const measure={larg:L, alt:+(d.h/d.w*L).toFixed(1), fonte:'dimensões do arquivo',
dpiFolha, px:d.w, grande:true, larguraDesconhecida:true};
if(dpiFolha>=DPI_MINIMO_FOLHA) measure.confirmar='desconhecida';
res(measure);
}).catch(()=>res(null));
return;
}
if(RENDERIZA.test(nome)){
carregarImagem(file).then(img=>{
if(!img || !img.width) return res(null);
const L=larguraFilme();
const L=larguraFilme(), dpiFolha=Math.round(img.width/(L/2.54));
// Uma imagem só é folha montada se tiver pixel para ocupar a largura do
// filme. Sem esta conferência, qualquer arte pequena vira "folha" e leva
// o preço por metro sem nunca ter sido montada.
res({larg:L, alt:+(img.height/img.width*L).toFixed(1), fonte:'proporção da imagem',
dpiFolha:Math.round(img.width/(L/2.54)), px:img.width});
const measure={larg:L, alt:+(img.height/img.width*L).toFixed(1), fonte:'proporção da imagem',
dpiFolha, px:img.width, larguraDesconhecida:true};
if(dpiFolha>=DPI_MINIMO_FOLHA) measure.confirmar='desconhecida';
res(measure);
});
return;
}
@@ -428,14 +437,14 @@ function medirFolha(file){
const w=vp.width*unit*PT_CM, h=vp.height*unit*PT_CM;
if(!Number.isFinite(w) || !Number.isFinite(h) || w<=0 || h<=0 || h>6000)
return {rejected:true, reason:'Esta página é grande demais. Divida a folha em partes menores.'};
// A página do PDF já diz a largura real: fora de 57 cm, recusa.
const exata=LARGURA_EXATA[modo];
if(exata!=null && Math.abs(w-exata)>LARGURA_TOLERANCIA_CM)
return {larguraErrada:{cm:w, dpi:null}};
// Keep precise geometry for the fit and quote; the UI rounds only
// when displaying dimensions.
return {larg:+w.toFixed(3), alt:+h.toFixed(3),
// A página do PDF já diz a largura real: mais larga que o filme, não entra;
// mais estreita, entra no tamanho real e pede confirmação.
const L=larguraFilme(), tol=LARGURA_TOLERANCIA_CM;
if(w>L+tol) return {largaDemais:{cm:w}};
const medida={larg:+Math.min(w,L).toFixed(3), alt:+h.toFixed(3),
fonte:'página do PDF'+(unit!==1 ? ' · UserUnit '+unit : '')};
if(w<L-tol) medida.confirmar='estreita';
return medida;
}).then(res).catch(()=>res({rejected:true,
reason:'Não conseguimos ler este PDF. Exporte de novo como PDF de uma página ou PNG.'}))
.finally(()=>{ if(doc) doc.destroy().catch(()=>{}); });