django-cms / django-filer

File and Image Management Application for django
https://django-filer.readthedocs.io/
Other
1.76k stars 577 forks source link

feat: Cache transparency property of image to improve thumbnail name prediction #1365

Closed fsbraun closed 1 year ago

fsbraun commented 1 year ago

Description

easy-thumbnails uses different formats for transparent pictures. This is configurable, but by default jpeg for regular and png for transparent images.

1353 introduced a heuristic to guess thumbnail names without having to hit the database. This heuristic greatly improves if it is known if the image has transparency (alpha channel).

This PR introduces a migration (BooleanField _transparent) in the File model.

@jrief Sorry, it does not yet introduce the JSONField you proposed in #1348. The reason is that the image fields, like width, height, are all currently part of the File model and not the Image model (for whatever reason). I could not handle polymorphism there yet.

Related resources

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #1365 (c98e3dc) into master (deafdc2) will increase coverage by 0.00%. The diff coverage is 83.33%.

@@           Coverage Diff           @@
##           master    #1365   +/-   ##
=======================================
  Coverage   73.26%   73.26%           
=======================================
  Files          73       74    +1     
  Lines        3336     3344    +8     
  Branches      542      542           
=======================================
+ Hits         2444     2450    +6     
- Misses        720      722    +2     
  Partials      172      172           
Impacted Files Coverage Δ
filer/models/abstract.py 80.80% <71.42%> (-0.72%) :arrow_down:
filer/migrations/0017_image__transparent.py 100.00% <100.00%> (ø)
filer/templatetags/filer_admin_tags.py 91.00% <100.00%> (-0.18%) :arrow_down: