vajiral / php-image-compare
一个轻量级的PHP类,可以比较两个(jpg/png)图像,以查找它们是否相似。
1.0.1
2017-05-04 01:48 UTC
Requires
- php: ^5.5.9 || ^7.0
- ext-gd: *
This package is auto-updated.
Last update: 2024-09-29 05:01:20 UTC
README
一个轻量级的PHP类,可以比较两个(jpg/png)图像,以查找它们是否相似。
支持的文件: "png","jpg"。
用法
通过composer安装
"vajiral/php-image-compare": "1.0.1"
在你的PHP文件中
<?php use BigV\ImageCompare; require __DIR__ . "/../vendor/autoload.php"; /** * These two images are almost the same so the hammered distance will be less than 10 * Try it with images like below: * 1. Two slightly different images * 2. Two completely different images * 3. Two same images (returned value 0) * 4. Two same image but with different size/aspect ratio (returned value ~0) */ $image = new ImageCompare(); echo $image->compare(__DIR__ . '/image2-resize.jpg',__DIR__ . '/image2.jpg'); ?>
最初取自 https://www.phpclasses.org/package/8255-PHP-Compare-two-images-to-find-if-they-are-similar.html,并添加了命名空间,然后添加到Composer