音楽で楽しみましょう!-Let's have fun with music!-
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
parent
7c3206bf83
commit
54c6d22102
517 changed files with 637 additions and 639 deletions
28
api/funquail_api/common/scripts/create_image_variations.py
Normal file
28
api/funquail_api/common/scripts/create_image_variations.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"""
|
||||
Compute different sizes of image used for Album covers and User avatars
|
||||
"""
|
||||
|
||||
from versatileimagefield.image_warmer import VersatileImageFieldWarmer
|
||||
|
||||
from funkwhale_api.common.models import Attachment
|
||||
|
||||
MODELS = [
|
||||
(Attachment, "file", "attachment_square"),
|
||||
]
|
||||
|
||||
|
||||
def main(command, **kwargs):
|
||||
for model, attribute, key_set in MODELS:
|
||||
qs = model.objects.exclude(**{f"{attribute}__isnull": True})
|
||||
qs = qs.exclude(**{attribute: ""})
|
||||
warmer = VersatileImageFieldWarmer(
|
||||
instance_or_queryset=qs,
|
||||
rendition_key_set=key_set,
|
||||
image_attr=attribute,
|
||||
verbose=True,
|
||||
)
|
||||
command.stdout.write(f"Creating images for {model.__name__} / {attribute}")
|
||||
num_created, failed_to_create = warmer.warm()
|
||||
command.stdout.write(
|
||||
f" {num_created} created, {len(failed_to_create)} in error"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue