diff --git a/gallery/__init__.py b/gallery/__init__.py index c7a40f9..7f4c6b1 100644 --- a/gallery/__init__.py +++ b/gallery/__init__.py @@ -5,21 +5,13 @@ print(""" | |_| | | | | | |_| | |__| __/ (_| \\__ \\ \\___/|_| |_|_|\\__, |_____\\___|\\__, |___/ |___/ |___/ -Created by Fluffy Bean - Version 140123 +Created by Fluffy Bean - Version 170123 """) -# Import base packages -import time -import sys -import os -import yaml - -# Import flask -from flask import * -from werkzeug.utils import secure_filename - -# Import dotenv +from flask import Flask, render_template from dotenv import load_dotenv +import yaml +import os def create_app(test_config=None): # create and configure the app @@ -27,6 +19,7 @@ def create_app(test_config=None): # Get environment variables load_dotenv(os.path.join(app.root_path, 'user', '.env')) + print("Loaded env") # Get config file with open(os.path.join(app.root_path, 'user', 'conf.yml'), 'r') as f: diff --git a/gallery/api.py b/gallery/api.py index 453405b..6ab06ea 100644 --- a/gallery/api.py +++ b/gallery/api.py @@ -24,11 +24,13 @@ def uploads(file, quality): img = Image.open(os.path.join(current_app.config['UPLOAD_FOLDER'], secure_filename(file))) img_ext = os.path.splitext(secure_filename(file))[-1].lower().replace('.', '') img_ext = set_ext[img_ext] + img_icc = img.info.get("icc_profile") # Get ICC profile as it alters colours # Resize image and orientate correctly img.thumbnail((quality, quality), Image.LANCZOS) img = ImageOps.exif_transpose(img) - img.save(buff, img_ext) + img.save(buff, img_ext, icc_profile=img_icc) + img.close() # Seek to beginning of buffer and return buff.seek(0) diff --git a/gallery/image.py b/gallery/image.py index 4f31706..e2664cd 100644 --- a/gallery/image.py +++ b/gallery/image.py @@ -25,7 +25,7 @@ def image(id): # Get exif data from image try: - file = Image.open(os.path.join(current_app.config['UPLOAD_FOLDER'], 'original', image['file_name'])) + file = Image.open(os.path.join(current_app.config['UPLOAD_FOLDER'], image['file_name'])) raw_exif = file.getexif() human_exif = {} diff --git a/gallery/templates/auth/login.html b/gallery/templates/auth/login.html index 7287d9f..6a83515 100644 --- a/gallery/templates/auth/login.html +++ b/gallery/templates/auth/login.html @@ -1,24 +1,43 @@ {% extends 'layout.html' %} {% block header %} - + {% endblock %} {% block content %}