summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Green <martin.speleo@gmail.com>2023-04-29 22:23:40 +0100
committerMartin Green <martin.speleo@gmail.com>2023-04-29 22:49:26 +0100
commit0b566575f3ba51e61349f3313cc02a5066b87033 (patch)
treeb006e68912ca7f813ca1e9671128b9a95eb6e9ad
parent73af227fb36668180fb7cb9cd4cd7745aea1157f (diff)
downloadtroggle-0b566575f3ba51e61349f3313cc02a5066b87033.tar.gz
troggle-0b566575f3ba51e61349f3313cc02a5066b87033.tar.bz2
troggle-0b566575f3ba51e61349f3313cc02a5066b87033.zip
Change uploaded images to jpg to png, for much smaller files
-rw-r--r--core/views/editor_helpers.py8
1 files 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"),
]