From 48fc431162362ac9585177825dfca5d9dde6276d Mon Sep 17 00:00:00 2001 From: henriquenakashima Date: Mon, 10 Jul 2023 14:26:16 -0400 Subject: [PATCH] Example code to use ICC profile --- .gitignore | 1 + crop_card.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bed957c..b8d5899 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ archive/ input_cards/ cropped_cards/ +icc/ sheets/ # Byte-compiled / optimized / DLL files diff --git a/crop_card.py b/crop_card.py index e5ce0e3..97ddbaf 100644 --- a/crop_card.py +++ b/crop_card.py @@ -2,7 +2,7 @@ import os from pathlib import Path from typing import List, Optional, Tuple -from PIL import Image, ImageDraw +from PIL import Image, ImageDraw, ImageCms import util @@ -170,6 +170,8 @@ class SheetLayout: def create_sheet(cropped_filepaths: List[Path], sheet_filepath: Path, sheet_layout: SheetLayout): sheet = Image.new('RGB', (sheet_layout.w, sheet_layout.h), 'white') + # icc_profile = ImageCms.getOpenProfile(str(BASE_DIR / 'icc' / 'AdobeRGB1998.icc')) + # Draw external guidelines draw = ImageDraw.Draw(sheet) color = 'black' @@ -225,6 +227,7 @@ def create_sheet(cropped_filepaths: List[Path], sheet_filepath: Path, sheet_layo draw.line([(right_x, bottom_y), (right_x - guide_len, bottom_y)], fill = color, width = guide_thickness) # Save sheet + # sheet.save(sheet_filepath, 'JPEG', dpi=(sheet_layout.dpi, sheet_layout.dpi), quality=100, subsampling=0, icc_profile=icc_profile.tobytes()) sheet.save(sheet_filepath, 'JPEG', dpi=(sheet_layout.dpi, sheet_layout.dpi), quality=100, subsampling=0)