Download the PHP package sapientpro/image-comparator without Composer

On this page you can find all versions of the php package sapientpro/image-comparator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package image-comparator

Image Comparator: Compare images using PHP

https://packagist.org/packages/sapientpro/image-comparator https://packagist.org/packages/sapientpro/image-comparator https://packagist.org/packages/sapientpro/image-comparator

Image Comparator is a PHP library for image comparison and hashing. You can compare 2 and more images using perceptual hashing method.

Based on https://github.com/kennethrapp/phasher package, with PHP 8 and PHPUnit support. The original project was abandoned in November 2017.

Perceptual hashing is a method to generate a hash of an image which allows multiple images to be compared by an index of similarity. You can find out more at The Hacker Factor and phash.org.

Installation

Prerequisites

To install the library, run:

composer require sapientpro/image-comparator

Usage

ImageComparator is the core class of the library:

After creating an instance you can use one of the methods available:

If the image path can't be resolved, ImageResourceException will be thrown:

Example usage:

We have two images:

https://github.com/sapientpro/image-comparator/blob/master/tests/images/ebay-image.png?raw=true

Equals1 Equals2

Now, let's compare them:

The higher the result, the higher the similarity of images.

Let's compare different images:

Equals1 Equals2

Rotation angle can be passed if compared image is rotated. You must pass \SapientPro\ImageComparator\Enum\ImageRotationAngle enum with one of the following values: D0 = 0 degress, D90 = 90 degrees, D180 = 180 degrees, D270 = 270 degrees

You can also use detect() method which will rotate the compared image and return the highest percentage of similarity:

With compareArray() and detectArray() methods you can compare the source image to any number of images you want. The behaviour is the same as in compare() and detect() methods.

If needed, you can create a square image resource from another image and pass it to compare(), compareArray(), detect(), detectArray and hashImage() methods:

If needed, you can convert the resulting array from hashImage() to a binary string and pass it to compareHashStrings() method:

By default, images are hashed using the average hashing algorithm, which is implemented in SapientPro\ImageComparator\Strategy\AverageHashStrategy. This strategy is initialized in the constructor of ImageComparator.

It is also possible to use difference hashing algorithm, implemented in SapientPro\ImageComparator\Strategy\DifferenceHashStrategy. To use it, you need to call ImageComparator's setHashStrategy() method and pass the instance of the strategy:

If the strategy is set by setHashingStrategy(), it will be used under the hood in other comparison methods:

Available methods

You can read about available methods in our wiki page


All versions of image-comparator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-gd Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sapientpro/image-comparator contains the following files

Loading the files please wait ....