Skip to content

Commit cddc8aa

Browse files
authored
Merge pull request #2 from sapientpro/feature/image-comparator-facade
Image Comparator Laravel
2 parents 4cb67b0 + b782248 commit cddc8aa

File tree

13 files changed

+7943
-1
lines changed

13 files changed

+7943
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
build
3+
vendor
4+
.phpunit.cache

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,38 @@
1-
Image Comparator Laravel
1+
# Image Comparator Laravel: Compare images using Laravel
2+
3+
This package is a wrapper of [Image Comparator package](https://github.com/sapientpro/image-comparator)
4+
adapted to use with Laravel via Facade. All methods of Image Comparator are available in the Facade.
5+
For the method reference visit the [wiki](https://github.com/sapientpro/image-comparator/wiki)
6+
7+
## Prerequisites
8+
* php 8.1 or higher
9+
* Laravel 8 or higher
10+
* Gd extension enabled
11+
12+
## Installation
13+
14+
You can install the package using Composer:
15+
`composer require sapientpro/image-comparator-laravel`
16+
17+
## Usage
18+
19+
You can start using the Image Comparator Facade by including it in your class:
20+
21+
```php
22+
use SapientPro\ImageComparatorLaravel\Facades\Comparator;
23+
24+
$imageHash = Comparator::hashImage('path_to_image.jpg')
25+
```
26+
27+
By default, the average hashing algorithm is user for hashing and comparing images.
28+
If you want to use difference hashing algorithm, you set it with `setHashStrategy()` function:
29+
30+
```php
31+
use SapientPro\ImageComparatorLaravel\Facades\Comparator;
32+
use SapientPro\ImageComparator\Strategy\DifferenceHashStrategy;
33+
34+
Comparator::setHashStrategy(new DifferenceHashStrategy());
35+
36+
$similarity = Comparator::compare('path_to_image1.jpg', 'path_to_image2.jpg') // will use difference hash algorithm
37+
```
38+

composer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "sapientpro/image-comparator-laravel",
3+
"description": "Compare images using Laravel",
4+
"license": [
5+
"MIT"
6+
],
7+
"authors": [
8+
{
9+
"name": "SapientPro",
10+
"email": "info@sapient.pro",
11+
"homepage": "https://sapient.pro/"
12+
}
13+
],
14+
"require": {
15+
"php": "^8.1",
16+
"sapientpro/image-comparator": "^1.0",
17+
"illuminate/support": "^8.0|^9.0|^10.0"
18+
},
19+
"autoload": {
20+
"psr-4": {
21+
"SapientPro\\ImageComparatorLaravel\\": "src"
22+
}
23+
},
24+
"autoload-dev": {
25+
"psr-4": {
26+
"SapientPro\\ImageComparatorLaravel\\Tests\\": "tests"
27+
}
28+
},
29+
"require-dev": {
30+
"squizlabs/php_codesniffer": "3.7.2",
31+
"phpunit/phpunit": "^10.0",
32+
"orchestra/testbench": "^8.0"
33+
},
34+
"scripts": {
35+
"phpcs": "vendor/bin/phpcs .",
36+
"tests-unit": "vendor/bin/phpunit --testsuite=unit"
37+
},
38+
"extra": {
39+
"laravel": {
40+
"providers": [
41+
"SapientPro\\ImageComparatorLaravel\\Providers\\ComparatorServiceProvider"
42+
],
43+
"aliases": {
44+
"Comparator": "SapientPro\\ImageComparatorLaravel\\Comparator\\Facades\\Comparator"
45+
}
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)