Example code to use ICC profile

This commit is contained in:
henriquenakashima 2023-07-10 14:26:16 -04:00
parent feb3ca36e6
commit 48fc431162
2 changed files with 5 additions and 1 deletions

1
.gitignore vendored
View file

@ -1,6 +1,7 @@
archive/ archive/
input_cards/ input_cards/
cropped_cards/ cropped_cards/
icc/
sheets/ sheets/
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files

View file

@ -2,7 +2,7 @@ import os
from pathlib import Path from pathlib import Path
from typing import List, Optional, Tuple from typing import List, Optional, Tuple
from PIL import Image, ImageDraw from PIL import Image, ImageDraw, ImageCms
import util import util
@ -170,6 +170,8 @@ class SheetLayout:
def create_sheet(cropped_filepaths: List[Path], sheet_filepath: Path, sheet_layout: 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') 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 external guidelines
draw = ImageDraw.Draw(sheet) draw = ImageDraw.Draw(sheet)
color = 'black' 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) draw.line([(right_x, bottom_y), (right_x - guide_len, bottom_y)], fill = color, width = guide_thickness)
# Save sheet # 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) sheet.save(sheet_filepath, 'JPEG', dpi=(sheet_layout.dpi, sheet_layout.dpi), quality=100, subsampling=0)