forked from expo/troggle
Change uploaded images to jpg to png, for much smaller files
This commit is contained in:
parent
73af227fb3
commit
0b566575f3
@ -74,9 +74,9 @@ def new_image_form(request, path):
|
|||||||
tscale = max(width / THUMBNAIL_WIDTH, height / THUMBNAIL_HEIGHT)
|
tscale = max(width / THUMBNAIL_WIDTH, height / THUMBNAIL_HEIGHT)
|
||||||
thumbnail = i.resize((int(width / tscale), int(height / tscale)), Image.ANTIALIAS)
|
thumbnail = i.resize((int(width / tscale), int(height / tscale)), Image.ANTIALIAS)
|
||||||
ib = io.BytesIO()
|
ib = io.BytesIO()
|
||||||
i.save(ib, format="png")
|
i.save(ib, format="jpeg", quality = 75)
|
||||||
tb = io.BytesIO()
|
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_rel_path, thumb_rel_path, desc_rel_path = form.get_rel_paths()
|
||||||
image_page_template = loader.get_template("image_page_template.html")
|
image_page_template = loader.get_template("image_page_template.html")
|
||||||
image_page = image_page_template.render(
|
image_page = image_page_template.render(
|
||||||
@ -146,8 +146,8 @@ class NewWebImageForm(forms.Form):
|
|||||||
def get_rel_paths(self):
|
def get_rel_paths(self):
|
||||||
f = self.cleaned_data["file_"]
|
f = self.cleaned_data["file_"]
|
||||||
return [
|
return [
|
||||||
self.directory / "i" / (f.name.rsplit(".", 1)[0] + ".png"),
|
self.directory / "i" / (f.name.rsplit(".", 1)[0] + ".jpg"),
|
||||||
self.directory / "t" / (f.name.rsplit(".", 1)[0] + ".png"),
|
self.directory / "t" / (f.name.rsplit(".", 1)[0] + ".jpg"),
|
||||||
self.directory / "l" / (f.name.rsplit(".", 1)[0] + ".html"),
|
self.directory / "l" / (f.name.rsplit(".", 1)[0] + ".html"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user