Added compile-time mozjpeg feature flag by radarhere · Pull Request #8645 · python-pillow/Pillow

Resolves #539

Pillow will currently detect and use MozJPEG if it is installed. However,

  1. Pillow will report

--- JPEG support ok, compiled for libjpeg-turbo 4.1.1

4.1.1 is not a libjpeg-turbo version. It is the MozJPEG version. So this PR detects MozJPEG, and updates the report to say 'compiled for mozjpeg 4.1.1'

I've also added features.check_feature("mozjpeg")

  1. Testing in Ubuntu on GitHub Actions, there are currently 12 test failures.

Our current default behaviour is to not save progressive JPEGs, as documented in the saving keyword arguments at https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#jpeg-saving

progressive
If present and true, indicates that this image should be stored as a progressive JPEG file.

However, mozjpeg does save progressive JPEGs by default, unlike libjpeg-turbo. If I change the 'compression profile' from 'best compression ratio (progressive, all mozjpeg extensions)' to 'libjpeg[-turbo] defaults (baseline, no mozjpeg extensions)', then after I relax some image comparison checks, our test suite passes.