forked from expo/troggle
convert uploaded images to RGB so that it can be saved as jpg
This commit is contained in:
parent
a70cf6cad3
commit
ffed6e3ba6
@ -73,9 +73,12 @@ def new_image_form(request, path):
|
|||||||
i = i.resize((int(width / scale), int(height / scale)), Image.ANTIALIAS)
|
i = i.resize((int(width / scale), int(height / scale)), Image.ANTIALIAS)
|
||||||
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 = i.convert('RGB')
|
||||||
i.save(ib, format="jpeg", quality = 75)
|
i.save(ib, format="jpeg", quality = 75)
|
||||||
tb = io.BytesIO()
|
tb = io.BytesIO()
|
||||||
|
thumbnail = thumbnail.convert('RGB')
|
||||||
thumbnail.save(tb, format="jpeg", quality = 70)
|
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")
|
||||||
|
Loading…
Reference in New Issue
Block a user