diff options
author | Martin Green <martin.speleo@gmail.com> | 2023-07-05 21:08:51 +0100 |
---|---|---|
committer | Martin Green <martin.speleo@gmail.com> | 2023-07-05 21:08:51 +0100 |
commit | ffed6e3ba60a8908b3bf4d0c12d1587406528462 (patch) | |
tree | 9d461b0b73673885e9ebab1ad95c952bb486a596 /core | |
parent | a70cf6cad3e91b1a400fac7653eaa35e28caaf7b (diff) | |
download | troggle-ffed6e3ba60a8908b3bf4d0c12d1587406528462.tar.gz troggle-ffed6e3ba60a8908b3bf4d0c12d1587406528462.tar.bz2 troggle-ffed6e3ba60a8908b3bf4d0c12d1587406528462.zip |
convert uploaded images to RGB so that it can be saved as jpg
Diffstat (limited to 'core')
-rw-r--r-- | core/views/editor_helpers.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/core/views/editor_helpers.py b/core/views/editor_helpers.py index 47660b6..17ae04b 100644 --- a/core/views/editor_helpers.py +++ b/core/views/editor_helpers.py @@ -73,9 +73,12 @@ def new_image_form(request, path): i = i.resize((int(width / scale), int(height / scale)), Image.ANTIALIAS) tscale = max(width / THUMBNAIL_WIDTH, height / THUMBNAIL_HEIGHT) thumbnail = i.resize((int(width / tscale), int(height / tscale)), Image.ANTIALIAS) + ib = io.BytesIO() + i = i.convert('RGB') i.save(ib, format="jpeg", quality = 75) tb = io.BytesIO() + thumbnail = thumbnail.convert('RGB') thumbnail.save(tb, format="jpeg", quality = 70) image_rel_path, thumb_rel_path, desc_rel_path = form.get_rel_paths() image_page_template = loader.get_template("image_page_template.html") |