A handy Python script that takes a folder of images and sorts them into named folders based on their dominant color. Useful if you want to group random images by a single pattern, in this case: their dominant color.
- Supports multiple image formats: PNG, JPG, JPEG, BMP, GIF, TIFF.
- Uses k-means clustering to determine the dominant color.
- Maps the dominant color to the closest predefined color name.
- Organizes images into folders named after the dominant color.
To sort images by their dominant color and move them to corresponding folders, run the following command:
python -m image_color_sorter.sorter /path/to/input/folder --destination_folder_base /path/to/output/folder
python -m image_color_sorter.sorter ./images --destination_folder_base ./sorted_images
This command will process all images in the ./images folder and sort them into subfolders in the ./sorted_images directory based on their dominant colors.
Clone the repository:
git clone https://github.com/alwalxed/dominant-color-image-sort.git
cd dominant-color-image-sort
Install the required dependencies:
pip install -r requirements.txt
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! If you have any ideas, suggestions, or improvements, feel free to open an issue or create a pull request.
- Fork the repository.
- Create your feature branch.
- Commit your changes.
- Push to the branch.
- Open a pull request.
- Your contribution will be reviewed, and once approved, it will be merged into the main branch.
Please make sure to update tests as appropriate.