+ def add_cut_lines(self, img):
+ line_ratio = 0.5
+ if self.bleed == 0:
+ return img
+ metr = Metric(self, self.scale)
+ draw = ImageDraw.Draw(img)
+ for corner_x, corner_y in ((0, 0), (metr.width, 0), (0, metr.height), (metr.width, metr.height)):
+ dir_x = 1 if corner_x == 0 else -1
+ dir_y = 1 if corner_y == 0 else -1
+ for offset in (-1, 0, 1):
+ draw.line((corner_x, corner_y + dir_y * metr.bleed + offset,
+ corner_x + dir_x * metr.bleed * line_ratio, corner_y + dir_y * metr.bleed + offset),
+ fill='black' if offset == 0 else 'white', width=1)
+ draw.line((corner_x + dir_x * metr.bleed + offset, corner_y,
+ corner_x + dir_x * metr.bleed + offset, corner_y + dir_y * metr.bleed * line_ratio),
+ fill='black' if offset == 0 else 'white', width=1)
+ return img
+