diff --git a/autopsy_app/funcs.py b/autopsy_app/funcs.py index 0b8bef8..79dbb66 100644 --- a/autopsy_app/funcs.py +++ b/autopsy_app/funcs.py @@ -1,9 +1,10 @@ import re import string import random -from flask import url_for -from autopsy_app import app, flask_bcrypt -from autopsy_app.model import Mortem, User +from io import BytesIO +from PIL import Image +from autopsy_app import flask_bcrypt +from autopsy_app.model import Mortem def define_mortem_url(): @@ -29,5 +30,14 @@ def auto_tag(content): m = tag_pattern.findall(content) return [tag.lower() for tag in m] + def get_tags(tags_data): return tags_data.strip("{}").split(",") + + +def resize_screenshot(scr): + img_byte_arr = BytesIO() + img = Image.open(scr) + img.resize((800, 600)) + img.save(img_byte_arr, format='PNG') + return img_byte_arr.getvalue() diff --git a/autopsy_app/routes.py b/autopsy_app/routes.py index 3aadd4e..087833c 100644 --- a/autopsy_app/routes.py +++ b/autopsy_app/routes.py @@ -10,7 +10,7 @@ from autopsy_app.mail import send_email, send_admin_email from autopsy_app.funcs import (define_mortem_url, choose_random_mortem, auto_tag, generate_password, - verify_password, get_tags) + verify_password, get_tags, resize_screenshot) @app.route('/') @@ -245,7 +245,7 @@ def support(): content = form.content.data attach = form.attach.data if attach: - attach_data = attach.read() + attach_data = resize_screenshot(attach.stream) else: attach_data = b'' now = datetime.datetime.utcnow() @@ -255,7 +255,7 @@ def support(): support_created=now, support_attach=attach_data, user_id=uid) - send_admin_email(db, support_case) + # send_admin_email(db, support_case) db.session.add(support_case) db.session.commit() flash('The Support Case has been created', 'warning') diff --git a/requirements.txt b/requirements.txt index ead4be4..b02e244 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,6 +18,7 @@ itsdangerous==1.1.0 Jinja2==2.11.3 Mako==1.1.4 MarkupSafe==1.1.1 +Pillow==8.2.0 psycopg2==2.8.6 pycparser==2.20 python-dateutil==2.8.1