-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from sapientpro/feature/image-comparator-facade
Image Comparator Laravel
- Loading branch information
Showing
13 changed files
with
7,943 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.idea | ||
build | ||
vendor | ||
.phpunit.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.