logs and save extension for preview
This commit is contained in:
parent
f09b5c2367
commit
9ea7c25085
|
|
@ -1,3 +1,5 @@
|
|||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import transaction
|
||||
|
|
@ -21,8 +23,13 @@ class Command(BaseCommand):
|
|||
sorl_width_height = sorl_settings['geometry_string'].split('x')
|
||||
|
||||
if int(sorl_width_height[0]) > width or int(sorl_width_height[1]) > height:
|
||||
_, file_ext = os.path.splitext(establishment.preview_image_url)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS(f'Optimize: {establishment.preview_image_url}, extension: {file_ext}'))
|
||||
|
||||
establishment.preview_image_url = get_thumbnail(
|
||||
file_=establishment.preview_image_url,
|
||||
**sorl_settings
|
||||
**sorl_settings,
|
||||
format='PNG' if file_ext[1:] == 'png' else 'JPEG'
|
||||
).url
|
||||
establishment.save()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user