-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSortomatic.py
More file actions
59 lines (41 loc) · 2.61 KB
/
Sortomatic.py
File metadata and controls
59 lines (41 loc) · 2.61 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
from PIL import Image
def get_image_size(image_path):
with Image.open(image_path) as img:
return img.size
def sort_images_by_size(directory):
image_files = [f for f in os.listdir(directory) if f.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.bmp'))]
images_with_sizes = [(get_image_size(os.path.join(directory, img)), img) for img in image_files]
sorted_images = sorted(images_with_sizes, key=lambda x: x[0][0] * x[0][1], reverse=True)
sorted_filenames = [img[1] for img in sorted_images]
return sorted_filenames
def clear_console():
os.system('cls' if os.name == 'nt' else 'clear')
while True:
clear_console()
ascii_art = """
\033[93m
.--.--. ___ ____ ___
/ / '. ,--.'|_ ,' , `. ,--.'|_ ,--,
| : /`. / ,---. __ ,-. | | :,' ,---. ,-+-,.' _ | | | :,' ,--.'|
; | |--` ' ,'\ ,' ,'/ /| : : ' : ' ,'\ ,-+-. ; , || : : ' : | |,
| : ;_ / / |' | |' |.;__,' / / / | ,--.'|' | || ,--.--. .;__,' / `--'_ ,---.
\ \ `. . ; ,. :| | ,'| | | . ; ,. :| | ,', | |,/ \ | | | ,' ,'| / \
`----. \' | |: :' : / :__,'| : ' | |: :| | / | |--'.--. .-. |:__,'| : ' | | / / '
__ \ \ |' | .; :| | ' ' : |__' | .; :| : | | , \__\/: . . ' : |__ | | : . ' /
/ /`--' /| : |; : | | | '.'| : || : | |/ ," .--.; | | | '.'|' : |__ ' ; :__
'--'. / \ \ / | , ; ; : ;\ \ / | | |`-' / / ,. | ; : ;| | '.'|' | '.'|
`--'---' `----' ---' | , / `----' | ;/ ; : .' \ | , / ; : ;| : :
---`-' '---' | , .-./ ---`-' | , / \ \ /
`--`---' ---`-' `----'
\033[0m"""
separator_line = "=" * 120
print(ascii_art)
print("\n\033[91mMade by Cheddlar\033[0m")
print(separator_line)
print()
directory_path = input("Please enter the directory path: ")
sorted_images = sort_images_by_size(directory_path)
for image in sorted_images:
print(image)
input("Press Enter to continue...")