-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess-img.py
More file actions
43 lines (35 loc) · 954 Bytes
/
process-img.py
File metadata and controls
43 lines (35 loc) · 954 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import argparse
from PIL import Image
# Create an ArgumentParser object
parser = argparse.ArgumentParser(description='Image processing tool.')
# Add command-line arguments
parser.add_argument(
'--input_image',
type=str,
required=True,
help='Path to the input image file.'
)
parser.add_argument(
'--output_image',
type=str,
default='output_image.jpg',
help='Path to the output image file (default: output_image.jpg).'
)
parser.add_argument(
'--format',
type=str,
default='JPEG',
help='Format to save the image in (default: JPEG).'
)
parser.add_argument(
'--quality',
type=int,
default=85,
help='Quality of the saved image (default: 85).'
)
# Parse command-line arguments
args = parser.parse_args()
# Process the image
image = Image.open(args.input_image)
image.save(args.output_image, format=args.format, quality=args.quality)
print(f'Processed image saved as {args.output_image}.')