npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

img-duplicates

v1.0.2

Published

Find duplicate images based on visual similarity

Readme

Image Duplicate Finder CLI tool and JavaScript library

A CLI tool and JavaScript library for detecting duplicate and visually similar images across your file system. Using perceptual hashing algorithms, it can identify images that are essentially the same even when they differ in resolution, file format, compression level, or have very minor edits.

Compatible JavaScript runtimes: Node.js, Deno and Bun

CLI Usage

Installation

Node.js

Requires Node.js to be installed.

Run directly without installation:

npx img-duplicates [options] <source...>

Or install globally:

npm install -g img-duplicates

Note: Depending on how you installed Node.js, the above command may require admin rights.

Deno

Requires Deno to be installed. You can run the tool directly from npm:

deno run --allow-read --allow-write --allow-env --allow-ffi --allow-sys npm:img-duplicates [options] <source...>

Bun

Requires Bun to be installed. You can run the tool directly with:

bunx img-duplicates [options] <source...>

Or install globally:

bun install -g img-duplicates

Usage

After installation, the CLI tool is globally available:

img-duplicates [options] <source...>

Arguments

  • source - One or more directories or image files to search for duplicates

Options

  • -h, --hash-size <size> - Hash size for perceptual hashing (default: 8)
  • -d, --max-duplicates <num> - Maximum number of duplicates per image (default: 100)
  • -m, --max-distance <dist> - Maximum distance for similarity matching (default: 5)
  • --delete - Delete duplicate images (keeps highest resolution, asks for confirmation)
  • --force-delete - Delete duplicate images without confirmation
  • --help - Show this help message
  • --version - Show version number

Examples

# Search a directory for duplicates (Node.js)
img-duplicates /path/to/images
# or with npx
npx img-duplicates /path/to/images

# Search multiple directories (Deno)
deno run --allow-read --allow-write --allow-env --allow-ffi --allow-sys npm:img-duplicates /path/to/dir1 /path/to/dir2

# With custom settings (Bun)
bunx img-duplicates --hash-size 16 --max-distance 3 /path/to/images

# Mix files and directories (npx)
npx img-duplicates /path/to/image1.jpg /path/to/image2.png /path/to/directory

# Delete duplicates with confirmation
img-duplicates --delete /path/to/images

# Delete duplicates without confirmation (use with caution!)
img-duplicates --force-delete /path/to/images

Note: When using --delete or --force-delete, the image with the highest resolution in each duplicate group will be kept, and all others will be deleted.

Programmatic Usage

Installation

Node.js

npm install img-duplicates

Deno

No installation needed, import directly from npm:

import findDuplicateImages from 'npm:img-duplicates';

Bun

bun add img-duplicates

Usage

Node.js / Bun

import findDuplicateImages from 'img-duplicates';

const duplicates = await findDuplicateImages('/path/to/images', {
  hashSize: 8,
  maxDuplicates: 100,
  maxDistance: 5
});

console.log(duplicates);

Deno

import findDuplicateImages from 'npm:img-duplicates';

const duplicates = await findDuplicateImages('/path/to/images', {
  hashSize: 8,
  maxDuplicates: 100,
  maxDistance: 5
});

console.log(duplicates);

API

findDuplicateImages(source, options?)

  • source: string | string[] - Path to a directory or array of paths to directories/files
  • options: Object (optional)
    • hashSize: number - Hash size for perceptual hashing (default: 8)
    • maxDuplicates: number - Maximum number of duplicates per image (default: 100)
    • maxDistance: number - Maximum distance for similarity matching (default: 5)

Returns: Promise<Array<Array<{ path: string; width: number; height: number }>>>

Each group of duplicates is sorted by resolution (highest resolution first).

Supported Image Formats

All image formats supported by sharp:

  • PNG (.png)
  • JPEG (.jpg, .jpeg)
  • WebP (.webp)
  • GIF (.gif)
  • AVIF (.avif)
  • TIFF (.tiff, .tif)
  • SVG (.svg)

How It Works

The tool uses:

  1. Perceptual Hashing (dHash) - Creates a hash based on the visual content of the image
  2. k-d Tree - For efficient similarity search
  3. Hamming Distance - To measure similarity between hashes

This allows finding images that are visually similar, even if they have different resolutions, compression, or minor edits.

License

MIT