diff --git a/TFR/server/account.py b/TFR/server/account.py index 0752bf8..29e889a 100644 --- a/TFR/server/account.py +++ b/TFR/server/account.py @@ -42,7 +42,7 @@ def settings(): if "file" in request.files and request.files['file'].filename: picture = request.files["file"] - file_ext = picture.filename.split(".")[-1] + file_ext = picture.filename.split(".")[-1].lower() file_name = f"{user.id}.{file_ext}" if file_ext not in UPLOAD_EXTENSIONS: @@ -51,11 +51,14 @@ def settings(): error.append(f"Picture must be less than {UPLOAD_EXTENSIONS / 1000000}MB!") image = Image.open(picture.stream) - image_x, image_y = image.size - image.thumbnail(( - min(image_x, UPLOAD_RESOLUTION), - min(image_y, UPLOAD_RESOLUTION) - )) + + # Resizing gifs is more work than it's worth + if file_ext != "gif": + image_x, image_y = image.size + image.thumbnail(( + min(image_x, UPLOAD_RESOLUTION), + min(image_y, UPLOAD_RESOLUTION) + )) if error: for err in error: @@ -66,7 +69,12 @@ def settings(): os.remove(os.path.join(UPLOAD_DIR, user.picture)) user.picture = file_name - image.save(os.path.join(UPLOAD_DIR, file_name)) + + if file_ext == "gif": + image.save(os.path.join(UPLOAD_DIR, file_name), save_all=True) + else: + image.save(os.path.join(UPLOAD_DIR, file_name)) + image.close() if username: