Commit 41b3d35d authored by kaiyou's avatar kaiyou Committed by GitHub

Merge pull request #2 from y0no/master

Add GIF support
parents 7079567c fa242d1a
from tedimg import app
from PIL import Image
from PIL import Image, ImageSequence
import os
import binascii
......@@ -43,7 +43,10 @@ def save_with_thumbnail(image, filename):
thumb_file = os.path.join(app.config["THUMB_STORAGE"], dest)
thumb_size = app.config["THUMB_SIZE"]
# Save the image and thumbnail
image.save(full_file, format=image.format)
if image.format == 'GIF':
image.save(full_file, format=image.format, save_all=True)
else:
image.save(full_file, format=image.format)
image.thumbnail((thumb_size, thumb_size))
image.save(thumb_file, format=image.format)
return dest
......@@ -19,8 +19,8 @@ def show(path):
@app.route('/upload', methods=['POST'])
def upload():
url = flask.request.form['url']
uploaded = flask.request.files['file']
url = flask.request.form.get('url')
uploaded = flask.request.files.get('file')
# Get an image object from the uploaded image or URL
try:
if uploaded:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment