-
Notifications
You must be signed in to change notification settings - Fork 5
/
get_max_dimensions.py
42 lines (36 loc) · 1.66 KB
/
get_max_dimensions.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
import sys
from common_funcs import get_max_dimensions
"""
This script finds the maximum width and maximum height of all images in a folder,
along with a list of image filenames that have the maximum width and maximum height.
It also finds the second maximum width and second maximum height, along with their respective
lists of image filenames.
Usage: python get_max_dimensions.py [image_directory]
Parameter:
image_directory: The path to the directory containing the images.
Return: tuple: A tuple containing:
* the maximum width (int)
* maximum height (int)
* a list of filenames of images with maximum width (list)
* a list of filenames of images with maximum height (list)
* the second maximum width (int), the second maximum height (int)
* a list of filenames of images with the second maximum width (list)
* a list of filenames of images with the second maximum height (list)
Example: python get_max_dimensions.py images/
"""
# Check if the correct number of arguments were provided
if len(sys.argv) != 2:
print(f"Usage: python {sys.argv[0]} image_directory")
print(f"Example: python {sys.argv[0]} images/")
sys.exit(1)
# Parse the input arguments
image_dir = sys.argv[1]
results = get_max_dimensions(image_dir)
print("The max width is: ", results[0])
print("The list of images with the max width is: ", results[2])
print("The max height is: ", results[1])
print("The list of images with the max height is: ", results[3])
print("The second max width is: ", results[4])
print("The list of images with the second max width is: ", results[6])
print("The second max height is: ", results[5])
print("The list of images with the second max height is: ", results[7])