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