2323import sys
2424from enum import IntEnum , IntFlag
2525from functools import reduce
26- from typing import Any
26+ from typing import Any , BinaryIO
2727
2828from . import Image , __version__
2929from ._deprecate import deprecate
@@ -237,7 +237,7 @@ def GRIDPOINTS(n: int) -> Flags:
237237
238238
239239class ImageCmsProfile :
240- def __init__ (self , profile ) :
240+ def __init__ (self , profile : str | BinaryIO | core . CmsProfile ) -> None :
241241 """
242242 :param profile: Either a string representing a filename,
243243 a file like object containing a profile or a
@@ -260,16 +260,16 @@ def __init__(self, profile):
260260 elif isinstance (profile , _imagingcms .CmsProfile ):
261261 self ._set (profile )
262262 else :
263- msg = "Invalid type for Profile"
263+ msg = "Invalid type for Profile" # type: ignore[unreachable]
264264 raise TypeError (msg )
265265
266- def _set (self , profile , filename = None ):
266+ def _set (self , profile : core . CmsProfile , filename : str | None = None ) -> None :
267267 self .profile = profile
268268 self .filename = filename
269269 self .product_name = None # profile.product_name
270270 self .product_info = None # profile.product_info
271271
272- def tobytes (self ):
272+ def tobytes (self ) -> bytes :
273273 """
274274 Returns the profile in a format suitable for embedding in
275275 saved images.
@@ -290,14 +290,14 @@ class ImageCmsTransform(Image.ImagePointHandler):
290290
291291 def __init__ (
292292 self ,
293- input ,
294- output ,
295- input_mode ,
296- output_mode ,
297- intent = Intent .PERCEPTUAL ,
298- proof = None ,
299- proof_intent = Intent .ABSOLUTE_COLORIMETRIC ,
300- flags = Flags .NONE ,
293+ input : ImageCmsProfile ,
294+ output : ImageCmsProfile ,
295+ input_mode : str ,
296+ output_mode : str ,
297+ intent : Intent = Intent .PERCEPTUAL ,
298+ proof : ImageCmsProfile | None = None ,
299+ proof_intent : Intent = Intent .ABSOLUTE_COLORIMETRIC ,
300+ flags : Flags | int = Flags .NONE ,
301301 ):
302302 if proof is None :
303303 self .transform = core .buildTransform (
@@ -320,18 +320,18 @@ def __init__(
320320
321321 self .output_profile = output
322322
323- def point (self , im ) :
323+ def point (self , im : Image . Image ) -> Image . Image :
324324 return self .apply (im )
325325
326- def apply (self , im , imOut = None ):
326+ def apply (self , im : Image . Image , imOut : Image . Image | None = None ) -> Image . Image :
327327 im .load ()
328328 if imOut is None :
329329 imOut = Image .new (self .output_mode , im .size , None )
330330 self .transform .apply (im .im .id , imOut .im .id )
331331 imOut .info ["icc_profile" ] = self .output_profile .tobytes ()
332332 return imOut
333333
334- def apply_in_place (self , im ) :
334+ def apply_in_place (self , im : Image . Image ) -> Image . Image :
335335 im .load ()
336336 if im .mode != self .output_mode :
337337 msg = "mode mismatch"
0 commit comments