Closed andre-fuchs closed 9 months ago
@andre-fuchs thank you very much for this.
We use pre-commit with black/ruff, and is one of the testing dependencies - https://github.com/wagtail/Willow/blob/main/pyproject.toml#L44
Can you run pre-commit install
then pre-commit run --all-files
to lint?
Thanks @zerolab. Just did learn about pre-commit and reformatted the code.
I added two methods to the class PillowImage()
to add the ICC color profile and the EXIF data. These are applied in the methods save_as_jpeg()
, save_as_png()
, save_as_webp()
and save_as_avif()
. New unit tests were added to test this implementation with two image files with different ICC profiles.
This was strongly inspired by #63, which also modified the auto_orient()
method. I think this was necessary to fix a bug caused by the Orientation EXIF tag. Not totally sure, though. Please double check if this is necessary.
Note: This workaround is not necessary anymore.
Thank you @andre-fuchs. Will aim to review and test ASAP
The changes to auto_orient
will also end up fixing #137.
Two birds with one stone!
Thanks @zerolab for tidying up!
Thank you for helping us take this over the finish line, @andre-fuchs! It has been way too long coming
Cannot wait to use it. Many of my clients were complaining about the color conversion in Wagtail. This should solve it.
Upgrading Wagtail via PIP doesn’t do the trick yet:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. wagtail 5.2.1 requires Willow[heif]<1.7,>=1.6.2, but you have willow 1.7.0 which is incompatible.
@andre-fuchs You can install version 1.6.3 instead: https://github.com/wagtail/Willow/releases/tag/v1.6.3. Wagtail's upper version boundary on Willow likely won't be updated until Wagtail 6.0 unless wagtail/wagtail#11272 is backported to the stable/5.2.x
branch.
Adds methods to keep the ICC color profile and EXIF data if supported for JPEG, PNG, WebP and AVIF file formats. Extends the unit tests accordingly. All tests passed.
Closes #114 Closes #137