A Python package for photo clustering and organization
Project description
PhotoCluster
A Python package for photo clustering and organization.
Installation
From PyPI (when published)
pip install photocluster
Usage
Python API
The package provides a simple function-based API for clustering photos:
from photocluster import photocluster
# Cluster photos with default sensitivity (0.2)
photocluster("/path/to/photos")
# Or specify a custom sensitivity
photocluster("/path/to/photos", sensitivity=0.3)
Parameters:
input_dir(str | Path): Directory containing images to clustersensitivity(float, optional): Clustering sensitivity as a proportion (0.0-1.0). Defaults to 0.2.- Lower values (e.g., 0.1-0.2) = stricter clustering
- Higher values (e.g., 0.5-0.8) = looser clustering
How it works:
- Scans the input directory for JPEG images (recursively)
- Computes perceptual hashes for each image
- Clusters similar images using DBSCAN algorithm
- Organizes images into
group_0/,group_1/, etc. subdirectories
Example:
from pathlib import Path
from photocluster import photocluster
# Cluster photos with default sensitivity (0.2)
photocluster(Path("~/Pictures/vacation"))
# Or use a custom sensitivity for looser clustering
photocluster(Path("~/Pictures/vacation"), sensitivity=0.25)
# After running, photos will be organized like:
# ~/Pictures/vacation/
# ├── group_0/
# │ ├── IMG_001.jpg
# │ └── IMG_002.jpg
# ├── group_1/
# │ ├── IMG_003.jpg
# │ └── IMG_004.jpg
# └── ...
Development
Setup development environment
git clone https://github.com/yourusername/photocluster.git
cd photocluster
uv sync --extra dev
Run tests
uv run pytest
Run tests with coverage
uv run pytest --cov=src/photocluster --cov-report=html
Code quality checks
# Format code
uv run ruff format .
# Check code
uv run ruff check .
# Type check
uv run ty check .
License
This project is licensed under the MIT License - see the LICENSE file for details.
Features
- Perceptual hashing: Uses imagehash library to compute perceptual hashes for similarity detection
- DBSCAN clustering: Uses scikit-learn's DBSCAN algorithm for robust clustering
- Multiprocessing: Automatically uses multiple CPU cores for faster processing
- JPEG support: Currently supports JPEG images (.jpg, .jpeg)
- In-place organization: Organizes photos into cluster subdirectories within the input directory
Changelog
0.1.0
- Initial release
- Basic photo clustering functionality using perceptual hashing
- Python API with
photocluster()function - Support for JPEG images
- Multiprocessing support for faster hash computation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file photocluster-0.1.0.tar.gz.
File metadata
- Download URL: photocluster-0.1.0.tar.gz
- Upload date:
- Size: 55.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b79a2c5f262f5cd332188b303e05810c52331bd9b4682491349a2079321f2c5
|
|
| MD5 |
8502374edd801931fbd2f6f0a0e0af0c
|
|
| BLAKE2b-256 |
93339191ff20e1079bbde15d1c3346f896256cfd4feaafb84725ef00acb91d6c
|
Provenance
The following attestation bundles were made for photocluster-0.1.0.tar.gz:
Publisher:
publish.yml on mdarwish228/photocluster
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
photocluster-0.1.0.tar.gz -
Subject digest:
5b79a2c5f262f5cd332188b303e05810c52331bd9b4682491349a2079321f2c5 - Sigstore transparency entry: 732543675
- Sigstore integration time:
-
Permalink:
mdarwish228/photocluster@e775625c14797c7dac834386c541fa972f3cd77d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mdarwish228
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e775625c14797c7dac834386c541fa972f3cd77d -
Trigger Event:
push
-
Statement type:
File details
Details for the file photocluster-0.1.0-py3-none-any.whl.
File metadata
- Download URL: photocluster-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c773cd4502e432d98d6232560e25489d72eb81101f9461dc9adfc43c1db9502
|
|
| MD5 |
fb817d3a698cfb0aedea0d0f3dbed583
|
|
| BLAKE2b-256 |
a8d113be55b9e9f6a99b0aa6fddbc15079ced17af7a4f1d4bac4d19ca5214e63
|
Provenance
The following attestation bundles were made for photocluster-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on mdarwish228/photocluster
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
photocluster-0.1.0-py3-none-any.whl -
Subject digest:
2c773cd4502e432d98d6232560e25489d72eb81101f9461dc9adfc43c1db9502 - Sigstore transparency entry: 732543682
- Sigstore integration time:
-
Permalink:
mdarwish228/photocluster@e775625c14797c7dac834386c541fa972f3cd77d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mdarwish228
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e775625c14797c7dac834386c541fa972f3cd77d -
Trigger Event:
push
-
Statement type: