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

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions 29 Image-Sorting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

# Package/Script Name

Image Sorter

- It is python based script to sort and group jpg files according to the image resolution into separate folders


## Setup instructions

Just run the script where the bunch of jpg files of different resolutions exists.


## Output

- before running the script

![Screenshot (47)](https://user-images.githubusercontent.com/58656215/114294251-e7e3e980-9aba-11eb-8feb-d5556ac1e770.png)

- after running the script

![Screenshot (50)](https://user-images.githubusercontent.com/58656215/114294355-aef84480-9abb-11eb-8445-417216e2179c.png)

![Screenshot (49)](https://user-images.githubusercontent.com/58656215/114294255-f0d4bb00-9aba-11eb-82e8-d59e74cfdd86.png)


## Author(s)

[Jagadeesh Relli](https://github.com/RJ535315)
39 changes: 39 additions & 0 deletions 39 Image-Sorting/imgSortingScript.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#cv2 is an Image processing library

import cv2
#for os manipulation
import os,glob

#Initializing counts for each resolution category
im_4k = 0
im_1080 = 0
im_720 = 0

#Creating directories for each resolution type
os.system("mkdir 4K")
os.system("mkdir 1080p")
os.system("mkdir 720p")
#Selecting images one by one
for image in glob.glob('*.jpg'):
print(image)
#Reading the image
img = cv2.imread(image)
#getting the image resolution
height, width, channel = img.shape
#Comparing image resolutions and grouping them accordingly to move to folders
if(width>=3840 and height>=2160):
os.system("move "+image+" 4K")
im_4k = im_4k+1
continue
if(width>=1920 and height>=1080):
os.system("move "+image+" 1080p")
im_1080 = im_1080+1
continue
if(width>=1280 and height>=720):
os.system("move "+image+" 720p")
im_720 = im_720+1
continue
#displaying the counts for each type
print(im_4k," 4K images moved to 4K folder")
print(im_1080," 1080p images moved to 1080p folder")
print(im_720," 720p images moved to 720p folder")
Morty Proxy This is a proxified and sanitized view of the page, visit original site.