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
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 trickbb6fb14closed); 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:
@@ -295,17 +295,34 @@ class Item(StrictModel):
|
||||
raise ValueError('Finished sheets must retain their original orientation')
|
||||
if placed != expected:
|
||||
raise ValueError('Production layout does not cover every source copy')
|
||||
# No piece on top of another: stacked pieces bill less film than they
|
||||
# print on, and print over each other. Swept down the film, so only
|
||||
# the pieces still open at each row are compared.
|
||||
boxes = sorted((p.y_cm, p.y_cm + p.length_cm, p.x_cm, p.x_cm + p.width_cm)
|
||||
for p in self.production.placements)
|
||||
open_boxes = []
|
||||
for top, bottom, left, right in boxes:
|
||||
open_boxes = [b for b in open_boxes if b[0] > top + tolerance]
|
||||
if any(l < right - tolerance and left < r - tolerance for _, l, r in open_boxes):
|
||||
raise ValueError('Duas peças da montagem ficaram uma sobre a outra. Monte o pedido de novo.')
|
||||
open_boxes.append((bottom, left, right))
|
||||
# Stacked pieces bill less film than they print on (bb6fb14).
|
||||
# output/revisao/contrato-encaixe-forma.md.
|
||||
stacked = 'Duas peças da montagem ficaram uma sobre a outra. Monte o pedido de novo.'
|
||||
if is_sheet:
|
||||
# Ready sheets go one under the other, never nested: no crossing
|
||||
# at all. Swept down the film, so only the pieces still open at
|
||||
# each row are compared.
|
||||
boxes = sorted((p.y_cm, p.y_cm + p.length_cm, p.x_cm, p.x_cm + p.width_cm)
|
||||
for p in self.production.placements)
|
||||
open_boxes = []
|
||||
for top, bottom, left, right in boxes:
|
||||
open_boxes = [b for b in open_boxes if b[0] > top + tolerance]
|
||||
if any(l < right - tolerance and left < r - tolerance for _, l, r in open_boxes):
|
||||
raise ValueError(stacked)
|
||||
open_boxes.append((bottom, left, right))
|
||||
else:
|
||||
# Loose art may be nested by its shape: rectangles cross where it
|
||||
# is clear, and the print file composes transparency (Sentry
|
||||
# DTF-WEB-2B). Two pieces in one place are refused here; ink that
|
||||
# would land on ink is refused when the film is composed
|
||||
# (app/printpng.py film_bands).
|
||||
step = Decimal('0.01')
|
||||
boxes = set()
|
||||
for p in self.production.placements:
|
||||
box = tuple(v.quantize(step) for v in (p.x_cm, p.y_cm, p.width_cm, p.length_cm))
|
||||
if box in boxes:
|
||||
raise ValueError(stacked)
|
||||
boxes.add(box)
|
||||
if self.quality_status == 'warning' and not self.quality_acknowledged:
|
||||
raise ValueError('Resolution warning must be acknowledged')
|
||||
return self
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user