Skip to content

Commit

Permalink
Merge pull request #2 from sapientpro/feature/image-comparator-facade
Browse files Browse the repository at this point in the history
Image Comparator Laravel
  • Loading branch information
vadymtsots authored May 4, 2023
2 parents 4cb67b0 + b782248 commit cddc8aa
Show file tree
Hide file tree
Showing 13 changed files with 7,943 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
build
vendor
.phpunit.cache
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
Image Comparator Laravel
# 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
```

48 changes: 48 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "sapientpro/image-comparator-laravel",
"description": "Compare images using Laravel",
"license": [
"MIT"
],
"authors": [
{
"name": "SapientPro",
"email": "[email protected]",
"homepage": "https://sapient.pro/"
}
],
"require": {
"php": "^8.1",
"sapientpro/image-comparator": "^1.0",
"illuminate/support": "^8.0|^9.0|^10.0"
},
"autoload": {
"psr-4": {
"SapientPro\\ImageComparatorLaravel\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"SapientPro\\ImageComparatorLaravel\\Tests\\": "tests"
}
},
"require-dev": {
"squizlabs/php_codesniffer": "3.7.2",
"phpunit/phpunit": "^10.0",
"orchestra/testbench": "^8.0"
},
"scripts": {
"phpcs": "vendor/bin/phpcs .",
"tests-unit": "vendor/bin/phpunit --testsuite=unit"
},
"extra": {
"laravel": {
"providers": [
"SapientPro\\ImageComparatorLaravel\\Providers\\ComparatorServiceProvider"
],
"aliases": {
"Comparator": "SapientPro\\ImageComparatorLaravel\\Comparator\\Facades\\Comparator"
}
}
}
}
Loading

0 comments on commit cddc8aa

Please sign in to comment.