diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py index ae9a361e943..1f9e141e8a0 100644 --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -3,11 +3,12 @@ import os import re import shutil +import sys from io import BytesIO import pytest -from PIL import Image, ImageMode, features +from PIL import Image, ImageMode, ImageWin, features from .helper import ( assert_image, @@ -200,6 +201,10 @@ def test_display_profile(): # try fetching the profile for the current display device ImageCms.get_display_profile() + if sys.platform == "win32": + ImageCms.get_display_profile(ImageWin.HDC(0)) + ImageCms.get_display_profile(ImageWin.HWND(0)) + def test_lab_color_profile(): ImageCms.createProfile("LAB", 5000) diff --git a/src/PIL/ImageCms.py b/src/PIL/ImageCms.py index ef2bc5c7e8d..4e58f1da8df 100644 --- a/src/PIL/ImageCms.py +++ b/src/PIL/ImageCms.py @@ -18,7 +18,7 @@ import sys from enum import IntEnum -from typing import BinaryIO +from typing import BinaryIO, SupportsInt from . import Image @@ -263,7 +263,7 @@ def apply_in_place(self, im: Image.Image) -> Image.Image: return im -def get_display_profile(handle=None): +def get_display_profile(handle: SupportsInt | None = None) -> ImageCmsProfile | None: """ (experimental) Fetches the profile for the current display device. @@ -276,9 +276,9 @@ def get_display_profile(handle=None): from . import ImageWin if isinstance(handle, ImageWin.HDC): - profile = core.get_display_profile_win32(handle, 1) + profile = core.get_display_profile_win32(int(handle), 1) else: - profile = core.get_display_profile_win32(handle or 0) + profile = core.get_display_profile_win32(int(handle or 0)) if profile is None: return None return ImageCmsProfile(profile)