PhotoCluster
A Python package for photo clustering and organization.
Installation
From PyPI
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 and Sony ARW images (recursively)
- Computes perceptual hashes for each image (ARW uses the embedded JPEG preview)
- 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 + ARW support: Supports JPEG (
.jpg,.jpeg) and Sony RAW (.arw) via embedded JPEG preview - In-place organization: Organizes photos into cluster subdirectories within the input directory
Changelog
0.2.0
- Support for Sony ARW via embedded JPEG preview hashing
- Case-insensitive image discovery (e.g.
.JPG/.ARW)
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
Metadata
Release files for photocluster 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| photocluster-0.2.0.tar.gz | 58.7 kB | With provenance | Details for photocluster-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| photocluster-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for photocluster-0.2.0-py3-none-any.whl |
Total release size: 71.9 kB
Release files / photocluster-0.2.0.tar.gz
| Download URL | photocluster-0.2.0.tar.gz |
|---|---|
| Size | 58.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1af98b036ba1d41d23207a9752db83a934f59c70a782ae2fa598a46b85e18f67
|
|
BLAKE2b-256 checksum How to use checksums |
01c74b5554a01efcb0e14fa7734d2faff7d651c31951afc6995dbf5f15b4da8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / photocluster-0.2.0-py3-none-any.whl
| Download URL | photocluster-0.2.0-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79902c5aa31a0a5907cf6da3ac7154c46646790bdcb70947b49ca42efd0c62ec
|
|
BLAKE2b-256 checksum How to use checksums |
b27db3e0490f7f83c6cf92b63d7d1b9447922ed6476847bf77894138e04e5908
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for photocluster 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for photocluster-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.