-
-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding updated histogram entropy implementations (#598)
As of version 6.1.0, the Pillow imaging library’s C module includes an optimized native entropy method: • https://github.com/python-pillow/Pillow/blob/master/CHANGES.rst#610-2019-07-01 This change detects and selects this new native method, if it is available in the version of Pillow available to `sorl-thumbnails`. Additionally, an optimized version of the existing Python entropy method is furnished as a fallback: rather than summing the entire histogram value set, the function calculates the product of the image dimensions and band count to arrive at the same number. It also uses generator expressions and the specialized `math.fsum(…)` and `math.log2(…)` library calls to improve on the performance of its predecessor without altering the algorithm. The appropriate image-entropy function is then conditionally added to the `sorl.thumbnail.engines.pil_engine.Engine` class as a `staticmethod` at module-load time. *) Additionally, this PR rounds out the smart-crop unit test Co-authored-by: Camilo Nova <[email protected]>
- Loading branch information
1 parent
f8aafc0
commit 55ed977
Showing
2 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters