PHP code example of capsulescodes / laravel-dominant-color

1. Go to this page and download the library: Download capsulescodes/laravel-dominant-color 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/ */

    

capsulescodes / laravel-dominant-color example snippets


$imageSrc = "heart.png";
$totalNumberOfColors = 5; // primary + secondary + 3 additional

DominantColor::fromFile($imageSrc, $totalNumberOfColors);


$colorInfo = [
	'primary' => 0xDEFDEF,
	'secondary' => 0xABCABC,
	'palette' => [
		0 => ['color' => 0xABCABC, 'score' => 0.8],
		/// etc
	];