Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dea7c5b

Browse files
python script file pushed
1 parent cd99401 commit dea7c5b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

‎Image-Sorting/imgSortingScript.py‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#cv2 is an Image processing library
2+
3+
import cv2
4+
#for os manipulation
5+
import os,glob
6+
7+
#Initializing counts for each resolution category
8+
im_4k = 0
9+
im_1080 = 0
10+
im_720 = 0
11+
12+
#Creating directories for each resolution type
13+
os.system("mkdir 4K")
14+
os.system("mkdir 1080p")
15+
os.system("mkdir 720p")
16+
#Selecting images one by one
17+
for image in glob.glob('*.jpg'):
18+
print(image)
19+
#Reading the image
20+
img = cv2.imread(image)
21+
#getting the image resolution
22+
height, width, channel = img.shape
23+
#Comparing image resolutions and grouping them accordingly to move to folders
24+
if(width>=3840 and height>=2160):
25+
os.system("move "+image+" 4K")
26+
im_4k = im_4k+1
27+
continue
28+
if(width>=1920 and height>=1080):
29+
os.system("move "+image+" 1080p")
30+
im_1080 = im_1080+1
31+
continue
32+
if(width>=1280 and height>=720):
33+
os.system("move "+image+" 720p")
34+
im_720 = im_720+1
35+
continue
36+
#displaying the counts for each type
37+
print(im_4k," 4K images moved to 4K folder")
38+
print(im_1080," 1080p images moved to 1080p folder")
39+
print(im_720," 720p images moved to 720p folder")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /