resize images upon upload using pillow
This commit is contained in:
parent
6e0cf41c1a
commit
f288d22994
@ -53,4 +53,4 @@ Id,Publication,Author,Year,Custodian,Fields,Type,Publishers,License,LicenseShort
|
||||
61,Mots de la cage aux ours - woorden uit de berenkuil,Constant,2012,Varia,"words, language, Bruxelles",Softcover,Constant,Copyleft,Copyleft,,,
|
||||
62,Snake rituals and switching circuits,Florian Cramer,2009,Danny,"mass communication, personal communication, new media",paperback,Piet Zwart Institute,Creative Commons Attribution-Share Alike 3.0,Creative Commons,The function of a medium is ultimately decided by its users and not by its creators,,
|
||||
63,Magium issue 1: On Eating in isolation,Alice Strete,2020,Varia,"food, sharing, personal stories, consumption",zine,Self Published,Free Art License,Free Art License,,,No one
|
||||
64,Networks of One's Own: three takes on taking care,"Varia, Constant and Colm O’Neill",2019,Varia,"Software, internet, taking care, homebrew",paperback,Varia,Copyleft,Copyleft,,Networks Of One’s Own is a periodic para-nodal1 publication that is itself collectively within a network2.,
|
||||
64,Networks of One's Own 2: three takes on taking care,"Varia, Constant and Colm O’Neill",2019,Danny,"Software, internet, taking care, homebrew",paperback,Varia,Copyleft,Copyleft,Networks Of One’s Own is a periodic para-nodal publication that is itself collectively within a network.,,Danny
|
||||
|
|
@ -14,6 +14,7 @@ from flask import (
|
||||
)
|
||||
from flask_wtf.csrf import CSRFProtect
|
||||
from werkzeug.utils import secure_filename
|
||||
from PIL import Image
|
||||
from rnrfeed.rnrfeeder import getevents, getlatestevent
|
||||
from uploadform import PublicationForm
|
||||
from borrowform import BorrowForm
|
||||
@ -31,6 +32,7 @@ from csvparser.csvparser import (
|
||||
csrf = CSRFProtect()
|
||||
APP = flask.Flask(__name__, static_folder="static")
|
||||
APP.config['SECRET_KEY'] = 'ty4425hk54a21eee5719b9s9df7sdfklx'
|
||||
APP.config['UPLOAD_FOLDER'] = 'tmpupload'
|
||||
csrf.init_app(APP)
|
||||
|
||||
|
||||
@ -128,9 +130,16 @@ def upcoming_or_latest():
|
||||
|
||||
def saveimage(image, id):
|
||||
"""helper function that can save images"""
|
||||
print(image.filename)
|
||||
image.save(os.path.join(APP.config['UPLOAD_FOLDER'], image.filename))
|
||||
orig_image = Image.open(
|
||||
os.path.join(APP.config['UPLOAD_FOLDER'] ,image.filename)
|
||||
)
|
||||
new_width = 640
|
||||
new_height = int(new_width * orig_image.height / orig_image.width)
|
||||
resized_image = orig_image.resize((new_width, new_height), Image.ANTIALIAS)
|
||||
filename = secure_filename("image-{0}.jpg".format(id))
|
||||
image.save(os.path.join("static/images/", filename))
|
||||
resized_image.save(os.path.join("static/images/", filename))
|
||||
os.remove(os.path.join(APP.config['UPLOAD_FOLDER'], image.filename))
|
||||
|
||||
|
||||
def checksecret(secret):
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 31 KiB |
@ -3,4 +3,5 @@ feedparser
|
||||
flask
|
||||
flask_wtf
|
||||
requests
|
||||
Pillow
|
||||
bcrypt
|
||||
|
Loading…
Reference in New Issue
Block a user