PHP code example of ckdot / product-image-color-extractor
1. Go to this page and download the library: Download ckdot/product-image-color-extractor library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ckdot / product-image-color-extractor example snippets
composer
use Ckdot\ProductImageColorExtractor\Services\Extraction;
use Ckdot\ProductImageColorExtractor\Models\ColorResult;
$service = new Extraction();
/**
* @var ColorResult[] $results
*/
$results = $service->getColors('/path/to/image.jpg');
foreach ($results as $result) {
$color = $result->getColor();
echo sprintf(
'R %d, G %d, B %d: Score is %f',
$color->getRed(),
$color->getGreen(),
$color->getBlue(),
$result->getScore()
);