Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix color management by keeping ICC color profiles and EXIF data in addition #136

Merged
merged 15 commits into from
Nov 26, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix the missing kwargs unpacking. Tidying up
  • Loading branch information
andre-fuchs committed Nov 2, 2023
commit 1195b63ec10f92048f88ff1b7715330b5a7f5ad8
9 changes: 3 additions & 6 deletions willow/plugins/pillow.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,8 @@ def add_icc_profile(self, image, kwargs):
"""
Take over the ICC color profile from the original image
"""
print('W I L L O W', 'ADD ICC PROFILE')
icc_profile = image.info.get('icc_profile')
if icc_profile is not None:
print('W I L L O W', 'ADD ICC PROFILE', 'GOT ICC PROFILE')
kwargs['icc_profile'] = icc_profile
return kwargs

Expand Down Expand Up @@ -219,7 +217,6 @@ def save_as_jpeg(
if progressive:
kwargs["progressive"] = True

print('W I L L O W', 'SAVE AS JPEG')
kwargs = self.add_icc_profile(image, kwargs)
kwargs = self.add_exif_data(image, kwargs)

Expand Down Expand Up @@ -300,7 +297,7 @@ def save_as_webp(
kwargs = self.add_icc_profile(self.image, kwargs)
kwargs = self.add_exif_data(self.image, kwargs)

self.image.save(f, "WEBP", kwargs)
self.image.save(f, "WEBP", **kwargs)
if apply_optimizers and not lossless:
self.optimize(f, "webp")
return WebPImageFile(f)
Expand Down Expand Up @@ -329,7 +326,7 @@ def save_as_heic(

kwargs = self.add_icc_profile(self.image, kwargs)

self.image.save(f, "HEIF", kwargs)
self.image.save(f, "HEIF", **kwargs)

if not lossless and apply_optimizers:
self.optimize(f, "heic")
Expand All @@ -345,7 +342,7 @@ def save_as_avif(self, f, quality=80, lossless=False, apply_optimizers=True):

kwargs = self.add_icc_profile(self.image, kwargs)

self.image.save(f, "AVIF", quality=quality)
self.image.save(f, "AVIF", **kwargs)

if not lossless and apply_optimizers:
self.optimize(f, "heic")
Expand Down