Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/PIL/ImageCms.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@
low-level profile object

"""
self.filename = None
self.product_name = None # profile.product_name
self.product_info = None # profile.product_info

if isinstance(profile, str):
if sys.platform == "win32":
Expand All @@ -256,23 +259,18 @@
profile_bytes_path.decode("ascii")
except UnicodeDecodeError:
with open(profile, "rb") as f:
self._set(core.profile_frombytes(f.read()))
self.profile = core.profile_frombytes(f.read())

Check warning on line 262 in src/PIL/ImageCms.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/ImageCms.py#L262

Added line #L262 was not covered by tests
return
self._set(core.profile_open(profile), profile)
self.filename = profile
self.profile = core.profile_open(profile)
elif hasattr(profile, "read"):
self._set(core.profile_frombytes(profile.read()))
self.profile = core.profile_frombytes(profile.read())
elif isinstance(profile, core.CmsProfile):
self._set(profile)
self.profile = profile
else:
msg = "Invalid type for Profile" # type: ignore[unreachable]
raise TypeError(msg)

def _set(self, profile: core.CmsProfile, filename: str | None = None) -> None:
self.profile = profile
self.filename = filename
self.product_name = None # profile.product_name
self.product_info = None # profile.product_info

def tobytes(self) -> bytes:
"""
Returns the profile in a format suitable for embedding in
Expand Down
Loading