Felguk commited on
Commit
ff65975
·
verified ·
1 Parent(s): 36f3930

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +13 -0
utils.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ def create_output_directory(directory="output"):
4
+ """Create output directory if it doesn't exist"""
5
+ if not os.path.exists(directory):
6
+ os.makedirs(directory)
7
+ return directory
8
+
9
+ def allowed_file(filename):
10
+ """Check if file has allowed extension"""
11
+ ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}
12
+ return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
13
+