-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_run.py
More file actions
29 lines (23 loc) · 822 Bytes
/
start_run.py
File metadata and controls
29 lines (23 loc) · 822 Bytes
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
# *-utf8-*
import os
from os.path import join
import shutil
from comm_def import ASSET_DIR
from custom import imgs_dir
from image_checker import get_checker, NotImageFileException
def start_run():
copy_images(ASSET_DIR)
def copy_images(asset_dir):
for file_name in os.listdir(asset_dir):
full_file_name = join(asset_dir, file_name)
with open(full_file_name, 'rb') as f:
try:
checker = get_checker(f)
except NotImageFileException:
continue
ext = checker.get_ext()
height, width = checker.get_size(f)
if not os.path.exists(imgs_dir):
os.makedirs(imgs_dir)
if width > height > 1000:
shutil.copy(full_file_name, join(imgs_dir, "{}.{}".format(file_name, ext)))