evlz / delta-e-bundle
此包已被放弃,不再维护。未建议替代包。
Solarys/colordiff 包的 Symfony 扩展包
0.1.1
2015-03-12 15:58 UTC
Requires
- php: ~5.4
- ext-imagick: *
- solarys/colordiff: ~1.0
- symfony/symfony: ~2.4
Requires (Dev)
- phpunit/phpunit: ~4.5
This package is auto-updated.
Last update: 2022-02-01 12:45:27 UTC
README
Symfony 扩展包,用于 PHP 实现 CIE76,用于查找颜色之间的差异
安装
添加到 composer
$ composer require evlz/delta-e-bundle:~0.1
添加到内核
<?php # app/AppKernel.php class AppKernel extends Kernel { public function registerBundles() { $bundles = array( # your bundles new Evlz\DeltaEBundle\EvlzDeltaEBundle(), ); } }
使用
主要函数 findColorsInImage
参数
- 图像路径
- 期望的颜色数组
- 步长(可选) - 颜色分布中处理的像素之间的距离
- 差值(可选) - 匹配的相似颜色值之间的 Lab 坐标 距离
<?php namespace Acme\DemoBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller class DefaultController extends Controller { public function someAction(Request $request) { $imagePath = '/path/to/image.jpg'; $colors = array( '#9c5925', '#ab6029', '#522810', '#ca6f04', '#5c371d', '#4f2f1a', '#1e1818', '#0f1a20', '#4c2f27', '#5c4537', ); $step = 50; $diff = 10; $colorFinder = $this->get('evlz_delta_e.finder'); $resultColorDistribution = $colorFinder->findColorsInImage($imagePath, $colors, $step, $diff); // other stuff } /** * other actions */ }