Comparing Images in Node.js with JIMP

Comparing Images in Node.js with JIMP

The JIMP npm package provides us with methods to compare image files for the purposes of identifying inadvertent duplication or deliberate plagiarism. In this article I will demonstrate how to use them, and along the way we will find out just how similar two images must be to be considered the same. Comparing Images in Node.js with JIMP. Spotting accidental duplication or deliberate theft of images

The JIMP npm package provides us with methods to compare image files for the purposes of identifying inadvertent duplication or deliberate plagiarism. In this article I will demonstrate how to use them, and along the way we will find out just how similar two images must be to be considered the same.

JIMP and its Image Comparison Methods

JIMP is the JavaScript Image Manipulation Program, and you can read the full documentation on its npm page.

If you just want to install it for this project then run:

npm install --save jimp

I will be using three methods for comparing images:

  • hash: this returns a 64 bit perceptual hash of an image. Unlike the cryptographic hashes you might be familiar with, perceptual hashes vary in a way roughly proportional to the differences in input, so the hashes of similar images will also be similar.
  • distance: the Hamming distance between the hashes of two images, ie. the number of bits which differ.
  • diff: the percentage difference between two images.

The JIMP documentation linked to above recommends using both distance and diff to compare images. If either are less than 0.15 then the images can be considered to be the same. They claim 99% success with 1% false positives.

However, there were a few unanswered questions in my mind about this process:

  • Does it work if one of the images has been converted to black and white?
  • Does it work if the images are different sizes?
  • Does it work if one of the images has been slightly enhanced, for example sharpened?
  • Does it work with heavy editing, for example if one image is highly pixellized?

nodejs jimp image-processing javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Image Processing in Node.js with Jimp

In this video, I will be showing you the powerful library Jimp for image manipulation in Node.js đź”´ Subscribe for more https://www.youtube.com/channel/UCMA8gV...

Image Processing in Node.js with Jimp

In this video, I will be showing you the powerful library Jimp for image manipulation in Node.js đź”´ Subscribe for more https://www.youtube.com/channel/UCMA8gV...

Editing Images with Convolution Matrices using Node.js and JIMP

Editing Images with Convolution Matrices using Node.js and JIMP - The phrase “convolution matrix” sounds a bit scary if you are not familiar with the topic but it is actually a very simple concept to understand and extremely powerful. The process is best explained with a diagram.

Image Processing in Node.js Using Jimp Library

You are requested by a client to watermark an entire library of images, as well as cropping them to a consistent resolution. In fact, your solution needs to be integrated within the client’s existing Javascript infrastructure. This can be done with a simple yet capable (relatively new) package for NodeJS, named Jimp.

Complete Guide to Mahotas Python Library for Image Processing

Processing an image in order to derive some meaningful information from the image is known as image processing. It can be called a scientific study where we apply different methods or functions on images to find out what are its different features. We can enhance the image or degrade the image in order to extract unique features.