GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - fetlife/pdq-ruby: Ruby Gem Wrapper for PDQ Hashing

This repository was archived by the owner on Oct 16, 2026. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

53 Commits
53 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
bin
bin
 
 
ext/pdq
ext/pdq
 
 
lib
lib
 
 
sig
sig
 
 
spec
spec
 
 
.gitignore
.gitignore
 
 
.kodiak.toml
.kodiak.toml
 
 
.prettierignore
.prettierignore
 
 
.rspec
.rspec
 
 
.standard.yml
.standard.yml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
Cargo.lock
Cargo.lock
 
 
Cargo.toml
Cargo.toml
 
 
Gemfile
Gemfile
 
 
Gemfile.lock
Gemfile.lock
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
Rakefile
Rakefile
 
 
pdq.gemspec
pdq.gemspec
 
 

Repository files navigation

Pdq-ruby

Gem Version Gem Downloads GitHub Workflow Status Code Climate maintainability

Description

pdq-ruby is a Ruby gem that provides a convenient wrapper around the PDQ (Photo DNA Quick) hash algorithm implementation. PDQ is a perceptual image hashing algorithm developed by Facebook (now Meta) that generates compact binary fingerprints of images. These fingerprints can be used to:

  • Detect duplicate or near-duplicate images
  • Identify similar images even after modifications
  • Perform efficient image similarity searches
  • Support content moderation and copyright protection

The gem provides a Ruby-friendly interface to the Rust-based PDQ implementation, making it easy to:

  • Generate PDQ hashes from images
  • Compare images for similarity
  • Handle various image formats
  • Process images efficiently with native performance

This gem is a wrapper of darwinium-com's pdqhash Rust implementation.

Installation

Add this line to your application's Gemfile:

gem 'pdq', git: 'https://github.com/fetlife/pdq-ruby.git'

And then execute:

bundle install

Or install it yourself as:

gem install pdq --source https://github.com/fetlife/pdq-ruby.git

Usage

Basic Usage

The gem provides a simple interface to generate PDQ hashes from images:

require 'pdq'

# Generate a PDQ hash from an image file
hash, quality = Pdq.pdq_hash("path/to/image.jpg")

# The hash is returned as a hexadecimal string
puts "PDQ Hash: #{hash}"
# => PDQ Hash: 31ab07638e54b8fc49bb6633b1449dc44ebb63f3934d9c5c6cb2678f935dc000

# The quality score indicates the quality of hash (0 - 1.0)
puts "Quality: #{quality}"
# => Quality: 1.0

Understanding the Output

The pdq_hash method returns an array containing two elements:

  1. The PDQ hash as a hexadecimal string (256 bits, represented as 64 hexadecimal characters)
  2. A quality score between 0.0 and 1.0 indicating the reliability of the hash
    • 1.0 indicates a high-quality hash
    • Lower scores suggest potential issues with the image or hash generation

Supported Image Formats

Supports any format handled by image::ImageReader.

Development

Setup

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Installation

To install this gem onto your local machine, run bundle exec rake install.

Releasing a New Version

To release a new version:

  1. Update the version number in version.rb
  2. Run bundle exec rake release

This will:

  • Create a git tag for the version
  • Push git commits and the created tag
  • Push the .gem file to rubygems.org

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fetlife/pdq-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the pdq-ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

Ruby Gem Wrapper for PDQ Hashing

Resources

Readme
MIT license

Code of conduct

Code of conduct
Activity
Custom properties

Stars

1 star

Watchers

5 watching

Forks

2 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.