-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpicture_handler.py
77 lines (57 loc) · 2.13 KB
/
picture_handler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import os
import secrets
from PIL import Image
from flask import url_for, current_app
def add_profile_pic(pic_upload,username):
filename = pic_upload.filename
ext_type = filename.split('.')[-1]
random = secrets.token_hex(8)
storage_filename = str(username) + '_'+ random +'.' +ext_type
filepath = os.path.join(current_app.root_path, 'static', storage_filename)
# Play Around with this size.
output_size = (200, 200)
# Open the picture and save it
pic = Image.open(pic_upload)
pic.thumbnail(output_size)
pic.save(filepath)
return storage_filename
def add_team_pic(pic_upload,username):
filename = pic_upload.filename
ext_type = filename.split('.')[-1]
random = secrets.token_hex(8)
storage_filename = str(username) + '_' +'team' + '_'+ random +'.' +ext_type
filepath = os.path.join(current_app.root_path, 'static', storage_filename)
#uh
# Play Around with this size.
output_size = (200, 200)
# Open the picture and save it
pic = Image.open(pic_upload)
pic.thumbnail(output_size)
pic.save(filepath)
return storage_filename
def add_rent_pic(pic_upload,username):
filename = pic_upload.filename
ext_type = filename.split('.')[-1]
random = secrets.token_hex(8)
storage_filename = str(username) + '_' +'rent' + '_'+ random +'.' +ext_type
filepath = os.path.join(current_app.root_path, 'static', storage_filename)
# Play Around with this size.
output_size = (1000,1000)
# Open the picture and save it
pic = Image.open(pic_upload)
pic.thumbnail(output_size)
pic.save(filepath)
return storage_filename
def add_knowledge_pic(pic_upload,username):
filename = pic_upload.filename
ext_type = filename.split('.')[-1]
random = secrets.token_hex(8)
storage_filename = str(username) + '_'+'knowledge'+ random +'.' +ext_type
filepath = os.path.join(current_app.root_path, 'static', storage_filename)
# Play Around with this size.
output_size = (1000,1000)
# Open the picture and save it
pic = Image.open(pic_upload)
pic.thumbnail(output_size)
pic.save(filepath)
return storage_filename