fix: loose art nested by shape passes checkout again, and ink on ink goes to hand preparation (DTF-WEB-2B)
All checks were successful
Build and deploy / Validate source (push) Successful in 51s
Build and deploy / Integration suite on a real stack (push) Successful in 8m15s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 1m27s

Since 27/11 (bb6fb14) the checkout refused any crossing rectangles. The Site
nests loose art by its shape (Misturado, and Automático when it saves film),
so rectangles cross where the art is clear, and honest carts were refused
with "Duas peças da montagem ficaram uma sobre a outra". The print file
composes with alpha_composite, so those layouts print right.

Loose art: two pieces in one place are still refused (the stacked-copies
price trick bb6fb14 closed); partial crossing passes. Ready sheets: any
crossing is still refused, sheets are never nested. When the film is
composed, ink landing on ink (alpha > 10 on the same pixel) raises
Unsupported, so the item goes to hand preparation with the reason instead of
printing over itself. Contract: output/revisao/contrato-encaixe-forma.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-02 09:09:25 -03:00
parent cc0db89705
commit 7af6c9797d
4 changed files with 123 additions and 17 deletions

View File

@@ -33,7 +33,7 @@ import struct
import zlib
from decimal import Decimal
from PIL import Image, ImageDraw, ImageFont, ImageOps
from PIL import Image, ImageChops, ImageDraw, ImageFont, ImageOps
from .core.models import PRODUCTION_VERSIONS
from .printfile import (FOOTER_CM, FOOTER_LOGO, FOOTER_LOGO_CM, MAX_DECODED_PIXELS, SUPPORTED_FORMATS,
@@ -730,6 +730,18 @@ def render(item, files, out_dir, prefix, footer=None, part_cm=None, tiles=False,
'min_dpi': round(lowest) if lowest else None}
def ink_meets_ink(band, rows, at):
"""Whether `rows`, put at `at` on `band`, would lay ink (alpha above
INK_ALPHA) where the band already has ink. Pieces nested by shape cross
rectangles only where one of them is clear (contrato-encaixe-forma.md P2)."""
x, y = at
under = band.crop((x, y, x + rows.width, y + rows.height)).getchannel('A')
if not under.getbbox():
return False
ink = lambda image: image.point(lambda a: 255 if a > INK_ALPHA else 0)
return ImageChops.multiply(ink(under), ink(rows.getchannel('A'))).getbbox() is not None
def film_bands(pieces, top, bottom, width):
"""The film's rows [top, bottom) composed, BAND_ROWS at a time: (band top,
RGBA image). Pieces are read forward only, so ranges go down the film."""
@@ -747,7 +759,10 @@ def film_bands(pieces, top, bottom, width):
left = max(0, -piece.x)
if left or piece.x + rows.width > width:
rows = rows.crop((left, 0, min(rows.width, width - piece.x), rows.height))
band.alpha_composite(rows, (max(0, piece.x), a - band_top))
at = (max(0, piece.x), a - band_top)
if ink_meets_ink(band, rows, at):
raise Unsupported('duas peças da montagem têm tinta no mesmo lugar')
band.alpha_composite(rows, at)
yield band_top, band
# A piece the film has passed is done with: its pixels can go.
for piece in pieces: