A Python UI to enable automation of sorting Camera Upload photos and videos by date, place, category.
Download a .exe to try out. Need both application.exe
and res
folder in same directory.
Require Python packages OpenCV, PyQt5, PIL for core functions.
After cloning the repository, run application.py
.
The GUI starts up in the Browse mode. Click "Browse" to browse for a directory to process images. If you have a path, you may input in Folder Path Input before clicking.
After browsing for a directory, all images and videos prefixed "IMG", "VID" and "PANO" respectively (normally default file prefixes by Camera Upload) are sorted into folders according to their shot date. (e.g. an image with path "dir/IMG_abc.png" shot at 4/Mar/2022 will be sorted into "dir/20220304" folder.)
For each date folder, all images within are displayed in the Image view mode in thumbnail display (for videos, first frame is taken). Here you may change the number of images per row, border width between images, sort images according to file name, file size etc. Double-click on any image to zoom in.
After viewing, select a category from dropdown or enter a new category (e.g. a place / food / activity etc.). Then click "Submit" when done.
This process repeats until all date folder are categorised. The GUI will return to Browse mode when done, with a "" message.
The program flow is outlined as in below diagram:
application.py
: serves as entry point to the application, triggers GUI to start up.gui.py
: loads and wires up fields inres/imagesort.ui
(you may use Qt Designer to modify its design). Main operation of sorting into folders, loading images into UI and categorising are in this file.imageutil.py
: Utility functions for image files, using OpenCV package, e.g. load, combine, add padding, scale and display into QLabel.videoutil.py
: Utility functions for video files, using OpenCV package, for now, only get first frame as thumbnail function.sort_folder_by_date.py
: Sort images / videos / panoramic images prefixed "IMG_", "VID_" and "PANO_" respectively in selected directory / directories into dated folder.logsetup.py
: Set up root logger and sub-loggers. Logger hierarchy in this project is one sub-logger for gui and sort_folder_by_date under root logger. All sub-logger messages are routed to root logger, and handled inlog/yyyymmdd.log
file.
- Auto-identify category through computer vision (OpenCV).
- Enter a backup directory. All images categorised will be copied to the backup directory in the same category folder.
Feel free to suggest!