-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
55 lines (48 loc) · 2.11 KB
/
__main__.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
import argparse
import logging
from configs import Config
from watermark import WaterMarker
LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
'-35s %(lineno) -5d: %(message)s')
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config_dir', default="config",
metavar='configuration_directory', type=str,
help='Configuration directory to use; if not specified, '
'default config directory will be used')
# Configuration file
parser.add_argument('-f', '--config_file', default="application.ini",
metavar='configuration_file', type=str,
help='Configuration file to use; if not specified, '
'default configs will be used')
parser.add_argument('--path',
help='Absolute path to the folder with the images to be watermarked.',
required=True)
parser.add_argument('--watermark_path',
help='Absolute path to the watermark file.',
required=True)
parser.add_argument('--save_path',
help='Absolute path to save the watermarked images, default is the same folder of the images',
required=False)
parser.add_argument('--show', help='If true will show the image after applying the watermark, default false',
default=False,
required=False)
args = parser.parse_args()
config_dir = args.config_dir
config_file = args.config_file
Config.init(config_dir, config_file)
path = args.path
watermark_path = args.watermark_path
show = args.show
if args.save_path:
save_path = args.save_path
else:
save_path = f'{path}/watermarked'
watermarker = WaterMarker(
path=path,
watermark_path=watermark_path,
save_path=save_path,
show=show
)
watermarker.create_watermarked_image()