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

View file

@ -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)