Skip to content

Commit fe26f4d

Browse files
authored
Update image-comparator to 1.2 (#4)
Update image-comparator version to 1.2
1 parent 1c5974e commit fe26f4d

File tree

5 files changed

+63
-14
lines changed

5 files changed

+63
-14
lines changed

.github/workflows/pr.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Image Comparator Laravel PR pipeline
2+
3+
on:
4+
pull_request:
5+
types:
6+
- assigned
7+
- opened
8+
- reopened
9+
- review_requested
10+
- synchronize
11+
12+
jobs:
13+
phpunit:
14+
runs-on: ubuntu-24.04
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
20+
- name: Set up PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.2'
24+
25+
- name: Install Composer dependencies
26+
run: composer install --prefer-dist --no-progress --no-suggest
27+
28+
- name: Run PHPUnit tests
29+
run: ./vendor/bin/phpunit --testsuite=unit
30+
31+
phpcs:
32+
runs-on: ubuntu-24.04
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v3
37+
38+
- name: Set up PHP
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: '8.2'
42+
43+
- name: Install Composer dependencies
44+
run: composer install --prefer-dist --no-progress --no-suggest
45+
46+
- name: Run PHP CodeSniffer
47+
run: ./vendor/bin/phpcs -p .

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"require": {
1515
"php": "^8.1",
16-
"sapientpro/image-comparator": "^1.1.0",
16+
"sapientpro/image-comparator": "^1.2",
1717
"illuminate/support": "^8.0|^9.0|^10.0|^11.0"
1818
},
1919
"autoload": {

composer.lock

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Facades/Comparator.php

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use SapientPro\ImageComparator\ImageComparator;
99
use SapientPro\ImageComparator\Strategy\HashStrategy;
1010

11+
// phpcs:disable Generic.Files.LineLength.TooLong
1112
/**
1213
* @method static void setHashStrategy(HashStrategy $hashStrategy)
1314
* @method static float compare(GdImage|string $sourceImage, GdImage|string $comparedImage, ImageRotationAngle $rotation = ImageRotationAngle::D0, int $precision = 1)
@@ -19,6 +20,7 @@
1920
* @method static GdImage|false squareImage(string $image)
2021
* @method static string convertHashToBinaryString(array $hash)
2122
*/
23+
// phpcs:enable Generic.Files.LineLength.TooLong
2224
class Comparator extends Facade
2325
{
2426
protected static function getFacadeAccessor(): string

tests/Unit/ComparatorTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function testCompareImages(): void
1616
'tests/images/amazon-image.png'
1717
);
1818

19-
$this->assertSame(87.5, $similarity);
19+
$this->assertSame(86.994, $similarity);
2020

2121
$similarityArray = Comparator::compareArray(
2222
'tests/images/ebay-image.png',
@@ -27,8 +27,8 @@ public function testCompareImages(): void
2727
);
2828

2929
$this->assertSame([
30-
'amazon1' => 87.5,
31-
'amazon2' => 53.1
30+
'amazon1' => 86.994,
31+
'amazon2' => 43.436
3232
], $similarityArray);
3333
}
3434

@@ -39,7 +39,7 @@ public function testDetectSimilarities(): void
3939
'tests/images/amazon-image.png'
4040
);
4141

42-
$this->assertSame(87.5, $similarity);
42+
$this->assertSame(86.994, $similarity);
4343

4444
$similarityArray = Comparator::detectArray(
4545
'tests/images/ebay-image.png',
@@ -50,8 +50,8 @@ public function testDetectSimilarities(): void
5050
);
5151

5252
$this->assertSame([
53-
'amazon1' => 87.5,
54-
'amazon2' => 62.5
53+
'amazon1' => 86.994,
54+
'amazon2' => 48.59
5555
], $similarityArray);
5656
}
5757

0 commit comments

Comments
 (0)