64 lines
1.6 KiB
Python
Executable File
64 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
#coding: utf-8
|
|
import cv2
|
|
import os
|
|
from os.path import join
|
|
|
|
def pic_size_find(pic_path: str):
|
|
img = cv2.imread(pic_path,0)
|
|
h, w = img.shape[:2]
|
|
return(w, h)
|
|
|
|
def pics_list(path:os.path):
|
|
files = [f for f in os.listdir(path) if (f.endswith(".jpg") or f.endswith(".jpeg") or f.endswith(".png"))]
|
|
|
|
return files
|
|
|
|
def file_move(file, dest):
|
|
os.rename(file, dest)
|
|
|
|
|
|
def main():
|
|
folder4k = "wallpapers4k"
|
|
folder2k = "wallpapers2k"
|
|
folderhd = "wallpapershd"
|
|
foldersd = "wallpaperssd"
|
|
folderuw = "wallpapersuw"
|
|
|
|
res4k = (4096, 2160)
|
|
res2k = (2560, 1440)
|
|
reshd = (1920, 1080)
|
|
resuw = (3440, 1440)
|
|
|
|
for folder in [folder4k, folder2k, folderhd, foldersd]:
|
|
os.makedirs(join(".", folder), exist_ok=True)
|
|
|
|
|
|
files = pics_list("./wallpapers")
|
|
for f in files:
|
|
f_path = join("wallpapers", f)
|
|
size = pic_size_find(f_path)
|
|
print(f"{f} => {size}")
|
|
if size == res4k:
|
|
file_move(f_path, join(folder4k, f))
|
|
dest_folder = folder4k
|
|
elif size == res2k:
|
|
file_move(f_path, join(folder2k, f))
|
|
dest_folder = folder2k
|
|
elif size == reshd:
|
|
file_move(f_path, join(folderhd, f))
|
|
dest_folder = folderhd
|
|
elif size == resuw:
|
|
file_move(f_path, join(folderuw, f))
|
|
dest_folder = folderuw
|
|
else:
|
|
file_move(f_path, join(foldersd, f))
|
|
dest_folder = foldersd
|
|
print(f"{f} moved to {dest_folder}")
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|