https://github.com/sapientpro/image-comparator-laravel
Compare images using Laravel
https://github.com/sapientpro/image-comparator-laravel
image-comparison image-hashing laravel laravel8 laravel9 php php8
Last synced: 11 months ago
JSON representation
Compare images using Laravel
- Host: GitHub
- URL: https://github.com/sapientpro/image-comparator-laravel
- Owner: sapientpro
- Created: 2023-04-25T11:53:51.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-09-20T12:00:10.000Z (almost 2 years ago)
- Last Synced: 2024-09-28T19:41:09.173Z (almost 2 years ago)
- Topics: image-comparison, image-hashing, laravel, laravel8, laravel9, php, php8
- Language: PHP
- Homepage:
- Size: 2.81 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Image Comparator Laravel: Compare images using Laravel



This package is a wrapper of [Image Comparator package](https://github.com/sapientpro/image-comparator)
adapted to use with Laravel via Facade. All methods of Image Comparator are available in the Facade.
For the method reference visit the [wiki](https://github.com/sapientpro/image-comparator/wiki)
## Prerequisites
* php 8.1 or higher
* Laravel 8 or higher
* Gd extension enabled
## Installation
You can install the package using Composer:
`composer require sapientpro/image-comparator-laravel`
## Usage
You can start using the Image Comparator Facade by including it in your class:
```php
use SapientPro\ImageComparatorLaravel\Facades\Comparator;
$imageHash = Comparator::hashImage('path_to_image.jpg')
```
By default, the average hashing algorithm is user for hashing and comparing images.
If you want to use difference hashing algorithm, you set it with `setHashStrategy()` function:
```php
use SapientPro\ImageComparatorLaravel\Facades\Comparator;
use SapientPro\ImageComparator\Strategy\DifferenceHashStrategy;
Comparator::setHashStrategy(new DifferenceHashStrategy());
$similarity = Comparator::compare('path_to_image1.jpg', 'path_to_image2.jpg') // will use difference hash algorithm
```