| Crates.io | immich-lib |
| lib.rs | immich-lib |
| version | 1.2.0 |
| created_at | 2025-12-29 08:59:45.020442+00 |
| updated_at | 2025-12-29 08:59:45.020442+00 |
| description | A Rust library for the Immich API focused on duplicate management |
| homepage | |
| repository | https://github.com/richardjlyon/immich-lib |
| max_upload_size | |
| id | 2010266 |
| size | 2,084,796 |
Warning: External Libraries Not Supported
This tool's metadata consolidation (GPS, timezone transfer) does not work with Immich External Libraries (library imports). Immich reads metadata from the source files for external libraries, so API updates don't persist.
This tool only works correctly with uploaded assets (files uploaded via the Immich app/web/CLI that Immich manages directly).
A Rust CLI tool for intelligent Immich duplicate management. Unlike Immich's built-in de-duplication which favors larger files, this tool selects the highest-quality image by dimensions while preserving metadata through consolidation.
Features:
Immich's duplicate detection works well, but its resolution logic is naive: keep the largest file, trash the rest. This ignores that:
With 2000+ duplicates, manual review isn't feasible. This tool automates smart selection with full backup safety.
The tool selects winners by largest dimensions (width × height), ensuring you keep the highest quality image. Metadata from losers (GPS, timezone) is consolidated to the winner before deletion.
brew install richardjlyon/tap/immich-dupes
Download from Releases for Linux, macOS, and Windows.
cargo install --git https://github.com/richardjlyon/immich-lib
Set your Immich credentials:
export IMMICH_URL="https://your-immich-server.com"
export IMMICH_API_KEY="your-api-key"
Or use command-line flags: -u <URL> -a <API_KEY>
immich-dupes analyze -o duplicates.json
This outputs a JSON file with all duplicate groups, scored assets, and conflict detection. Review the file to spot-check decisions.
immich-dupes execute -i duplicates.json -b ./backups
This will:
./backups/--force)Options:
--skip-review - Skip groups with metadata conflicts that need manual review--yes - Skip confirmation prompt--rate-limit <N> - Max API requests per second (default: 10)--concurrent <N> - Max concurrent operations (default: 5)immich-dupes verify duplicates.json
Checks that all winners still exist and all losers have been deleted.
If something went wrong:
immich-dupes restore -b ./backups
Re-uploads all backed-up files to Immich.
# 1. Analyze your duplicates
immich-dupes analyze -o analysis.json
# 2. Review the JSON (optional)
cat analysis.json | jq '.groups | length' # See group count
cat analysis.json | jq '.needs_review_count' # See conflicts
# 3. Execute with backups
immich-dupes execute -i analysis.json -b ./backups --skip-review
# 4. Verify the results
immich-dupes verify analysis.json
# 5. If needed, restore
immich-dupes restore -b ./backups
iPhones can save photos in both 4:3 (full sensor) and 16:9 (cropped) formats simultaneously. This creates near-duplicate pairs that Immich's CLIP-based detection doesn't catch because they're semantically identical but have different aspect ratios.
The letterbox command finds and removes these pairs:
# 1. Analyze for letterbox pairs
immich-dupes letterbox analyze -o letterbox.json
# 2. Review the analysis
cat letterbox.json | jq '.pairs | length' # Count of pairs found
# 3. Execute removal (backs up 16:9 crops, keeps 4:3 originals)
immich-dupes letterbox execute -i letterbox.json -b ./letterbox-backups
# 4. Verify results
immich-dupes letterbox verify letterbox.json
--force)The analysis shows:
When a loser has metadata the winner lacks, it's transferred:
| Field | Consolidated |
|---|---|
| GPS coordinates | Yes |
| Timezone | Yes |
| Description | Yes |
| Camera make/model | No (Immich API limitation) |
MIT