Only external bleed

This commit is contained in:
henriquenakashima 2023-07-13 01:06:17 -04:00
parent 89e20fd61e
commit 088181085e
3 changed files with 165 additions and 73 deletions

View file

@ -8,7 +8,7 @@ from PIL import Image, ImageDraw, ImageCms
from base_proxy import BASE_DIR
from card_images import InputCardImage
import sheet_layout
from sheet_layout import SheetLayout
from sheet_layout import SheetLayout, CardImageTransfer
import util
@ -44,16 +44,20 @@ def create_sheet(input_cards: List[InputCardImage], sheet_filepath: Path, layout
guide_thickness = layout.in_to_px(CUT_GUIDE_WIDTH_INCHES)
for x_index in range(layout.cards_per_column):
left_x = layout.left_of_column(x_index, with_bleed=False)
right_x = layout.right_of_column(x_index, with_bleed=False)
draw.line([(left_x, 0), (left_x, layout.h)], fill=color, width=guide_thickness)
draw.line([(right_x, 0), (right_x, layout.h)], fill=color, width=guide_thickness)
left_x = layout.card_area_left_xs[x_index]
right_x = layout.card_area_right_xs[x_index]
min_y = layout.min_padding
max_y = layout.h - 1 - layout.min_padding
draw.line([(left_x, min_y), (left_x, max_y)], fill=color, width=guide_thickness)
draw.line([(right_x, min_y), (right_x, max_y)], fill=color, width=guide_thickness)
for y_index in range(layout.cards_per_row):
top_y = layout.top_of_row(y_index, with_bleed=False)
bottom_y = layout.bottom_of_row(y_index, with_bleed=False)
draw.line([(0, top_y), (layout.w, top_y)], fill=color, width=guide_thickness)
draw.line([(0, bottom_y), (layout.w, bottom_y)], fill=color, width=guide_thickness)
top_y = layout.card_area_top_ys[y_index]
bottom_y = layout.card_area_bottom_ys[y_index]
min_x = layout.min_padding
max_x = layout.w - 1 - layout.min_padding
draw.line([(min_x, top_y), (max_x, top_y)], fill=color, width=guide_thickness)
draw.line([(min_x, bottom_y), (max_x, bottom_y)], fill=color, width=guide_thickness)
# Draw cards
input_cards_iter = input_cards.__iter__()
@ -64,18 +68,19 @@ def create_sheet(input_cards: List[InputCardImage], sheet_filepath: Path, layout
except StopIteration:
break
card_im = input_card.get_cropped_and_resized(layout)
sheet.paste(card_im, layout.topleft_of_card_with_bleed(y_index, x_index))
image_transfer: CardImageTransfer = layout.create_card_image_transfer(y_index, x_index)
card_im = input_card.get_cropped_and_resized(layout, image_transfer)
sheet.paste(card_im, image_transfer.topleft_dest)
# Draw internal guidelines
color = 'magenta'
guide_len = layout.in_to_px(LENGTH_CUT_GUIDE_INCHES)
# -1 because the pixels are in [0, W - 1] and [0, H - 1]
left_x = layout.left_of_column(x_index, with_bleed=False)
right_x = layout.right_of_column(x_index, with_bleed=False) - 1
top_y = layout.top_of_row(y_index, with_bleed=False)
bottom_y = layout.bottom_of_row(y_index, with_bleed=False) - 1
left_x = layout.card_area_left_xs[x_index]
right_x = layout.card_area_right_xs[x_index] - 1
top_y = layout.card_area_top_ys[y_index]
bottom_y = layout.card_area_bottom_ys[y_index] - 1
# Top left
draw.line([(left_x, top_y), (left_x, top_y + guide_len)], fill = color, width = guide_thickness)