Skip to content

Commit c04fd3f

Browse files
committed
refactor image resizer to support better control over redimension, threads, logging and output of images
1 parent cc73d33 commit c04fd3f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

batch_resizer/main.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import re
1313

1414
from logger import Logger
15+
from help import print_help
1516

1617
CURRENT_VERSION = '1.0.0'
1718
VALID_FORMATS = ['.jpg', '.jpeg', '.png', '.webp']
@@ -27,6 +28,9 @@
2728
def main():
2829
args = parse_arguments()
2930

31+
if args.help:
32+
return print_help()
33+
3034
if args.verbose:
3135
log.set_verbosity(args.verbose)
3236

@@ -128,7 +132,7 @@ def process_image(img_path, formats=None, width=None, height=None, dest=None):
128132
# Output one file per format
129133
for f in output_formats:
130134

131-
# If img is being resized, append new dimensions to output filename
135+
# If img was resized, append new dimensions to output filename
132136
if width or height:
133137
dimensions = f'_{img.width}-{img.height}'
134138
img_path = pathlib.Path(img_path.stem + dimensions)
@@ -189,6 +193,9 @@ def parse_arguments():
189193
action='version',
190194
version=f'%(prog)s v{CURRENT_VERSION}'
191195
)
196+
parser.add_argument('--help',
197+
action='store_true',
198+
)
192199

193200
return parser.parse_args()
194201

0 commit comments

Comments
 (0)