Perceptual Image Hashing
for Dart
Generate compact, fixed-length fingerprints from images to find duplicates, detect similar images, and perform content-based image retrieval with ease.
Multiple Hashing Algorithms
Choose from four different perceptual hashing algorithms, each optimized for different use cases
Average Hash (aHash)
Fast and simple hashing comparing pixels against image average
Perceptual Hash (pHash)
Robust hashing using discrete cosine transform
Difference Hash (dHash)
Efficient hashing based on adjacent pixel comparisons
Wavelet Hash (wHash)
Advanced hashing using Haar wavelet transform
Simple to Use
Get started with just a few lines of code
import 'dart:io';
import 'package:image/image.dart' as img;
import 'package:dart_imagehash/dart_imagehash.dart';
void main() {
// Load images
final image1 = img.decodeImage(File('image1.jpg').readAsBytesSync())!;
final image2 = img.decodeImage(File('image2.jpg').readAsBytesSync())!;
// Calculate hashes
final hash1 = ImageHasher.averageHash(image1);
final hash2 = ImageHasher.averageHash(image2);
// Compare similarity
final distance = hash1 - hash2;
final similarity = 1.0 - (distance / hash1.length);
print('Similarity: ${(similarity * 100).toStringAsFixed(2)}%');
}
Perfect for Many Use Cases
From content moderation to duplicate detection, image hashing has countless applications
Duplicate Detection
Find and remove duplicate images from your collection
Similar Image Search
Locate visually similar images even with modifications
Content Moderation
Detect inappropriate content variations automatically
Quick Installation
Add dart_imagehash to your project in seconds
dart pub add dart_imagehash