Skip to content

Commit

Permalink
Update image-comparator to 1.2 (#4)
Browse files Browse the repository at this point in the history
Update image-comparator version to 1.2
  • Loading branch information
vadymtsots authored Jan 17, 2025
1 parent 1c5974e commit fe26f4d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 14 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Image Comparator Laravel PR pipeline

on:
pull_request:
types:
- assigned
- opened
- reopened
- review_requested
- synchronize

jobs:
phpunit:
runs-on: ubuntu-24.04

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPUnit tests
run: ./vendor/bin/phpunit --testsuite=unit

phpcs:
runs-on: ubuntu-24.04

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHP CodeSniffer
run: ./vendor/bin/phpcs -p .
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"php": "^8.1",
"sapientpro/image-comparator": "^1.1.0",
"sapientpro/image-comparator": "^1.2",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0"
},
"autoload": {
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/Facades/Comparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use SapientPro\ImageComparator\ImageComparator;
use SapientPro\ImageComparator\Strategy\HashStrategy;

// phpcs:disable Generic.Files.LineLength.TooLong
/**
* @method static void setHashStrategy(HashStrategy $hashStrategy)
* @method static float compare(GdImage|string $sourceImage, GdImage|string $comparedImage, ImageRotationAngle $rotation = ImageRotationAngle::D0, int $precision = 1)
Expand All @@ -19,6 +20,7 @@
* @method static GdImage|false squareImage(string $image)
* @method static string convertHashToBinaryString(array $hash)
*/
// phpcs:enable Generic.Files.LineLength.TooLong
class Comparator extends Facade
{
protected static function getFacadeAccessor(): string
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/ComparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testCompareImages(): void
'tests/images/amazon-image.png'
);

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

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

$this->assertSame([
'amazon1' => 87.5,
'amazon2' => 53.1
'amazon1' => 86.994,
'amazon2' => 43.436
], $similarityArray);
}

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

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

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

$this->assertSame([
'amazon1' => 87.5,
'amazon2' => 62.5
'amazon1' => 86.994,
'amazon2' => 48.59
], $similarityArray);
}

Expand Down

0 comments on commit fe26f4d

Please sign in to comment.