Blazing fast ๐ and memory-safe perceptual hashing application built with Rust!
A terminal user interface (TUI) application for computing perceptual hashes of images and finding similar images with convenient preview capabilities. Hash computation is performed using multi-threading for optimal performance.
Project realized as a part of Rust Course at AGH University of Krakow by:
- Aleksander Jรณลบwik - [OlaszPL]
- Piotr Kacprzak - [pkacprzak5]
- ๐ผ๏ธ Perceptual hashing with two algorithms:
- dHash (Difference Hash)
- pHash (Perceptual Hash)
- ๐ Similar image detection with visual preview
- ๐ Built-in file explorer for folder selection
- โก Multi-threaded processing for blazing fast performance
- ๐จ Interactive TUI built with Ratatui
- ๐ข 64-bit hash computation
- ๐ฅ๏ธ Cross-platform support (Linux & Windows)
The application provides an intuitive TUI interface with:
- Built-in file explorer - Navigate and select folders containing images
- Algorithm selection - Choose between dHash and pHash algorithms
- Results browser - View similar images with side-by-side preview of source and similar images
- Rust (edition 2024 or higher)
- Cargo (Rust package manager)
You can download pre-built binaries for your platform from the releases page.
Available architectures:
- Linux x86_64
- Windows x86_64
Important
- The Windows version does not support image display in the terminal.
- On Linux, image display in the terminal is only supported in terminals listed in the
ratatui-image compatibility matrix.
./perceptual-hashing.\perceptual-hashing.exe-
Clone the repository
git clone https://github.com/OlaszPL/perceptual-hashing.git cd perceptual-hashing -
Build the project
cargo build --release
-
Run the application
cargo run --release
The application implements two proven perceptual hashing algorithms:
- Fast computation - ideal for real-time processing
- Good performance on brightness/contrast variations
- Lower memory usage
- Best for: Quick similarity detection
- Higher accuracy - more robust similarity detection
- Better resilience to image transformations
- DCT-based approach for perceptual similarity
- Best for: Precise duplicate detection
Both algorithms produce 64-bit hashes and use Hamming distance for similarity comparison (lower distance = more similar images).
The TUI provides an intuitive workflow:
- Browse directories using arrow keys
- Press
cto select a folder for processing - Press
qto exit
- Choose between dHash (red) and pHash (blue)
- Use arrow keys or mouse to toggle selection
- Press
Enterto confirm
- Real-time progress with "CALCULATING" indicator
- Processing time displayed in the top-right corner
- Multi-threaded computation for optimal performance
- Left Panel: List of all processed images
- Center Panel: Similar images with Hamming distance scores (0 = identical)
- Right Panel: Side-by-side preview of selected and similar images
- Navigate with arrow keys, press
Escto go back
The project includes comprehensive unit tests for the hashing algorithms:
# Run all tests
cargo testTests cover:
- dHash algorithm correctness and consistency
- pHash algorithm accuracy and edge cases
- Hash computation validation
- Folder permissions: The application cannot access folders without proper read permissions
- Minimum images: Processing requires at least 2 images in the selected directory
- Hash size: All computed hashes are 64-bit for optimal performance and accuracy
- Image formats: Supports common formats (JPEG, PNG, etc.)
- Performance: Processing time scales with image count and selected algorithm
- Language: Rust ๐ฆ (memory-safe and blazing fast!)
- TUI Framework: Ratatui
This project is licensed under the MIT License - see the LICENSE file for details.
