|
| 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