From 0b566575f3ba51e61349f3313cc02a5066b87033 Mon Sep 17 00:00:00 2001 From: Martin Green Date: Sat, 29 Apr 2023 22:23:40 +0100 Subject: [PATCH] Change uploaded images to jpg to png, for much smaller files --- core/views/editor_helpers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/views/editor_helpers.py b/core/views/editor_helpers.py index cd1638b..8a556c4 100644 --- a/core/views/editor_helpers.py +++ b/core/views/editor_helpers.py @@ -74,9 +74,9 @@ def new_image_form(request, path): tscale = max(width / THUMBNAIL_WIDTH, height / THUMBNAIL_HEIGHT) thumbnail = i.resize((int(width / tscale), int(height / tscale)), Image.ANTIALIAS) ib = io.BytesIO() - i.save(ib, format="png") + i.save(ib, format="jpeg", quality = 75) tb = io.BytesIO() - thumbnail.save(tb, format="png") + 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") image_page = image_page_template.render( @@ -146,8 +146,8 @@ class NewWebImageForm(forms.Form): def get_rel_paths(self): f = self.cleaned_data["file_"] return [ - self.directory / "i" / (f.name.rsplit(".", 1)[0] + ".png"), - self.directory / "t" / (f.name.rsplit(".", 1)[0] + ".png"), + self.directory / "i" / (f.name.rsplit(".", 1)[0] + ".jpg"), + self.directory / "t" / (f.name.rsplit(".", 1)[0] + ".jpg"), self.directory / "l" / (f.name.rsplit(".", 1)[0] + ".html"), ]