Platform Pub Package License: MIT Donate Issue Forks Stars

dhash is a dart library which is used to calculate similarity between images based on dhash algorithm.

Lets Get Started

1. Depend on it

Add this to your package's pubspec.yaml file:


2. Install it

You can install packages from the command line:

with pub:

$  pub get

with Flutter:

$  flutter packages get

3. Import it

Now in your Dart code, you can use:

    import 'package:dhash/dhash.dart';



    import 'dart:io';
    import 'package:dhash/dhash.dart';

Read image File

    var imageBytes = File('path_to_image_file.jpg').readAsBytesSync();

Calculate dhash of the image

    var dhashOfImage = DHASH.calculateHash(imageBytes);

Create Hamming between two images

    /// Image 1 bytes
    var imageBytes1 = File('path_to_image_file1.jpg').readAsBytesSync();
    /// Image 2 bytes
    var imageBytes2 = File('path_to_image_file2.jpg').readAsBytesSync();
    /// dhash of Image 1
    var hashOfImage1 = DHASH.calculateHash(imageBytes1);
    /// dhash of Image 2
    var hashOfImage2 = DHASH.calculateHash(imageBytes2);
    /// Hamming between image 1 and image 2
    var hamming = DHASH.hamming(hashOfImage1, hashOfImage2);

Donate (How much ?. It's upto you !!)