-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathprocess_images.py
More file actions
34 lines (27 loc) · 1.11 KB
/
Copy pathprocess_images.py
File metadata and controls
34 lines (27 loc) · 1.11 KB
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
from pictures_collection.image_processing import ImageProcessor
from os import makedirs, getcwd, rename
from os.path import join
from argparse import ArgumentParser
from pathlib import Path
parser = ArgumentParser()
parser.add_argument("input_folder", type=Path)
args = parser.parse_args()
if args.input_folder.exists():
input_dir = args.input_folder
theme = str(args.input_folder).split("/")[-1]
output_dir = join('Images', theme)
makedirs(output_dir, exist_ok=True)
processor = ImageProcessor()
all_images = processor.find_all_images_files_in_directory(input_dir)
all_images.sort()
for count, image in enumerate(all_images):
processor.process_image(
filepath=f'{input_dir}/{image}',
output_size=(150, 150),
output_path=f'{output_dir}/carte-{count}.gif')
last_image = f'carte-{len(all_images) -1}.gif'
filepath = join(getcwd(), output_dir, last_image)
rename(filepath, join(getcwd(), output_dir, 'blankCard.gif'))
print(f'All images processed and saved in {output_dir}.')
else:
print(f'Folder {args.input_folder} does not exist.')