image_hashing 0.1.1 copy "image_hashing: ^0.1.1" to clipboard
image_hashing: ^0.1.1 copied to clipboard

A Dart library for generating perceptual hashes (AHash, PHash, DHash, WHash) from images, providing efficient single-image hash computation and comparison.

image_hashing #

Pub Version Pub Points License GitHub Workflow Status

NOTE: UNDER DEVELOPMENT!

A Dart library for generating perceptual hashes (AHash, PHash, DHash, WHash) from images, providing efficient single-image hash computation and comparison with pure Dart implementation.

Compatibility: Dart ^3.6.0

๐Ÿš€ Getting Started #

Installation #

Method 1 (Recommended) With Dart:

dart pub add image_hashing

With Flutter:

flutter pub add image_hashing

Method 2 Add to pubspec.yaml:

dependencies:
  image_hashing: ^0.1.1

Then run:

dart pub get

Basic Usage #

import 'package:image_hashing/image_hashing.dart';

void main() {
  final hasher = AHash(); // or other hasher types
  final hashRes = hasher.encodeImage("YourImageFile");
}

Currently only AHash is supported, to validate the whole process.

encodeImage will return you a String of hash value.

For AHash and PHash, it will be 64 bits (After hashing, you will obtain an $(8 \times 8)$ image).

For DHash, it will be 128 bits (Here, I decide to use both row difference and column difference to increase the countability, so you will obtain 2 $(8 \times 8)$ images).

WHash is still under-planning.

๐Ÿ“ฆ Features #

  • Core Feature 1: Different Hashing Methods

    final ahasher = AHash();
    final phasher = PHash();
    final dhasher = DHash();
    final whasher = WHash(); // Wavelet Transform Hashing dependency is under development
    

    To encode an image:

    final ahasher = AHash(useCV: false); // OpenCV compatibility is under development
    final ahash = ahasher.encodeImage("YourImageFile");
    
  • Core Feature 2: Hamming Distances of Image Hashing After hashing, you can use the following function to calculate the Hamming Distances

    final distance = hammingDistance(a, b, size: 64)
    

    where a and b are the hash strings. size is 64 for AHash and PHash, 128 for DHash.

    Result will in an int value.

๐Ÿงช Testing #

Unit tests are under development. Currently only unit tests for hamming distance

dart test

๐Ÿค Contributing #

Workflow #

  1. Fork repository
  2. Create feature branch:
    git checkout -b feat/your-feature
    
  3. Follow Conventional Commits:
    git commit -m "feat: add new validation method"
    

Code Style #

Follow the Effective Dart and analysis_options.yaml

๐Ÿ“š Documentation #

๐Ÿ“œ License #

BSD 3-Clause "New" or "Revised" License ยฉ 2025 RequieMa

Full text at LICENSE

๐Ÿšง Maintenance Status #

Basic functionalities are under development.

Please report issues via GitHub Issues

1
likes
160
points
55
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart library for generating perceptual hashes (AHash, PHash, DHash, WHash) from images, providing efficient single-image hash computation and comparison.

Repository (GitHub)
View/report issues

Topics

#photos #images #hash #dart

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

collection, image, logging, path

More

Packages that depend on image_hashing