Duplicate detection
LibrePhotos can detect duplicate photos in your library using both exact file matching and visual similarity analysis. This helps you reclaim storage space and keep your library clean.
Types of Duplicates​
Exact Copies​
Photos that are byte-for-byte identical. These are detected by comparing file hashes (MD5). This catches files that have been copied to multiple locations or imported more than once.
Not released yet (comes after 1.7.0) Two exact copies in one folder that a scan processed at the same moment could become two photos of one file, showing the same picture twice. A scan now always makes one photo of them, and updating to 1.8.0 merges the photos such a scan made into one, which keeps the albums, tags, faces and highest rating of each. The kept photo keeps its own caption, date, location and edit; the edit of a copy that was dropped is kept only when the kept photo had none.
Visual Duplicates​
Photos that look the same but may differ in resolution, quality, compression, or minor edits. These are detected using perceptual hashing — a technique that creates a fingerprint of what an image looks like, rather than its raw bytes. Two images with similar perceptual hashes are visually similar even if the files are technically different.
How Detection Works​
Perceptual Hashing​
LibrePhotos computes a 64-bit perceptual hash (pHash) for each image using a DCT-based (Discrete Cosine Transform) algorithm. This hash captures the visual structure of the image and is robust against:
- Resizing
- Minor compression differences
- Small color adjustments
- Format conversions (e.g. JPEG → PNG)
Two images are considered visually similar when their Hamming distance (the number of differing bits) is below a threshold.
The perceptual hash is computed while a photo is scanned, from its large thumbnail, and visual duplicate detection only looks at photos that already have one. Photos indexed before this feature was added have no hash, and an ordinary scan skips files it has already indexed — so Detect duplicates can report no visual duplicates on an older library.
To fill in the missing hashes, run a Rescan once from the Library page — open the dropdown next to Scan and choose Rescan; this re-processes every photo. Exact-copy detection uses the file's MD5 hash and isn't affected.
Two-Pass Algorithm​
For large collections, LibrePhotos uses a memory-efficient two-pass algorithm:
-
Pass 1 — Photos are processed in batches (default 10,000). Within each batch, a BK-tree data structure enables fast Hamming distance lookups to find duplicates.
-
Pass 2 — Cross-batch comparison ensures duplicates that span different batches are also found.
This approach keeps memory usage manageable even with hundreds of thousands of photos.
Using Duplicate Detection​
Finding Duplicates​
- Open Organizing → Duplicate photos: in the dropdown of the Photos page title, choose Duplicates under Organizing. While duplicates wait for review, a N duplicates to review card at the bottom of the sidebar opens the same page.
- Open the Detection options dropdown and choose what to look for. Do this before you start detection — the detect button runs immediately with whatever options are currently set:
- Exact file copies (identical content) — find byte-identical files
- Visual duplicates (similar images) — find visually similar photos
- Visual sensitivity — Strict (fewer matches, higher confidence), Normal, or Loose (more matches, may include false positives). This only appears while Visual duplicates is enabled.
- Clear pending duplicates — remove existing pending groups before detection runs. Not released yet (comes after 1.7.0) A group you resolve while the clearing runs stays resolved, with its Revert & restore photos; up to 1.7.0 it could be deleted with the pending ones.
- Click "Detect duplicates". Detection starts straight away using the options you selected.
The Detection options aren't remembered between runs, so set them each time you detect. The default Visual sensitivity and Clear pending duplicates values come from Settings → Photos → Advanced → Duplicate photos (there called How alike two photos must be and Start each search with an empty list) and can be changed there; the Exact file copies and Visual duplicates checkboxes always start enabled.
Detection runs as a background job. You can monitor progress in the Job System.
Reviewing Duplicates​
Once detection is complete, duplicates appear as groups on the Organizing → Duplicate photos page:
- Each group shows preview thumbnails of the duplicate photos
- Badges indicate the type (exact copy or visual duplicate) and review status
- Potential space savings shows how much storage you'd free by keeping only one copy
Filtering Results​
Use the filters at the top to narrow down results:
- Review status: Pending review, Resolved, Dismissed, or All
- Type: Exact Copies or Visual Duplicates
Resolving a Duplicate Group​
Click on a duplicate group to open the review modal:
- Each photo is shown with its resolution, file size, camera, date, and file path
- The highest-resolution photo is automatically pre-selected as the one to keep
- The pre-selected photo's button reads "Keep this"; every other photo shows a "Select" button. To keep a different photo, click its "Select" button — that photo's button then changes to "Keep this"
- Click "Keep selected & trash others" — the other photos are moved to trash
- The group status changes to Resolved
New in 1.7.0 Exact copies have the same picture, so two photos of a group can share an image hash; the one you select is the one kept. Up to 1.6.0, keeping one of them failed with "Something went wrong on the server", and selecting one marked both. For scripts, POST /api/duplicates/{id}/resolve/ takes the photo's id as keep_photo_id; keep_photo_hash still works and keeps the first of the photos with that hash. Not released yet (comes after 1.7.0) It keeps the first of them that is out of the trash, so resolving the visual group by hash after the exact group keeps the copy the exact group kept; only when every photo with that hash is in the trash does it answer 409 kept_photo_in_trash. Up to 1.7.0 it took the first photo with that hash even when it was in the trash.
Not released yet (comes after 1.7.0) A photo is often in two groups: an exact copy is also in the visual duplicate group of the same picture. A group therefore shows only its photos that are out of the trash, plus the ones its own resolution moved there, and never pre-selects a photo in the trash. When the photo you keep went to the trash in the meantime (resolving the other group trashed it, perhaps in another tab), resolving answers The photo to keep is in the trash. Restore it first, or keep another photo. and changes nothing. Up to 1.7.0, resolving the exact group and then the visual group could move every copy of a photo to the trash. Scripts get a 409 with the code kept_photo_in_trash. Not released yet (comes after 1.7.0) The photo count of a group, in the list and in the group itself, counts the same photos the group shows, so a group with fewer than two of them left is no longer listed. After a refused resolve the group reloads, so the photo that went to the trash disappears from it. Up to 1.7.0 the list counted every photo of the group, the trashed ones too.
Other Actions​
- "Not duplicates" — Dismiss the group if the photos aren't actually duplicates. The group's status changes to Dismissed and it is listed under the Dismissed filter with its photos. Detection does not offer these photos again; a group that gains a new photo (a further copy found later) goes back to Pending review. Dismissing a resolved group first takes the photos its resolution trashed out of the trash. New in 1.7.0 Up to 1.6.0, dismissing unlinked the photos, so a dismissed group was listed nowhere and the next detection offered the same photos again.
- "Revert & restore photos" — For resolved groups only: undo the resolution, restore the photos that resolving moved to the trash, and set the group back to Pending review. A photo of the group that you trashed yourself, before or after resolving, stays in the trash. Dismissed groups can't be reverted. New in 1.7.0 Up to 1.6.0, reverting restored every photo of the group that was in the trash.
- Delete group — Remove the duplicate group record entirely.
Batch Operations​
You can select multiple duplicate groups using the checkboxes and delete them in bulk.
Tips​
- Start with exact copies — These are guaranteed duplicates and safe to clean up
- Review visual duplicates carefully — Similar-looking photos from a burst sequence or different angles may not be true duplicates
- Use strict sensitivity first — Strict gives you high-confidence matches to review. A later run can still form new groups from photos that weren't matched, but visual detection skips any photo already in a visual-duplicate group, so a looser re-run won't add members to groups the strict run already created. To re-evaluate those photos, first clear their groups — enable Clear pending duplicates when you re-run (this deletes pending groups only; resolved groups are kept and their photos stay excluded), or delete the individual groups
- The batch size parameter can be tuned in the detection API for systems with limited memory (smaller batches use less RAM but take longer)