1. Go to this page and download the library: Download brianmcdo/image-palette 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/ */
brianmcdo / image-palette example snippets
>= 5.4
5-gd
// initiate with image
$palette = new \BrianMcdo\ImagePalette\ImagePalette( 'https://www.google.co.uk/images/srpr/logo3w.png' );
// get the prominent colors
$colors = $palette->colors; // array of Color objects
// to string as json
echo $palette; // '["#ffffdd", ... ]'
// implements IteratorAggregate
foreach ($palette as $color) {
// Color provides several getters/properties
echo $color; // '#ffffdd'
echo $color->rgbString; // 'rgb(255,255,221)'
echo $color->rgbaString; // 'rgba(255,255,221,0.25)'
echo $color->int; // 0xffffdd
echo $color->rgb; // array(255,255,221)
echo $color->rgba; // array(255,255,221,0.25)
// ...
}
$palette = new \BrianMcdo\ImagePalette\ImagePalette( $src, 5 /* precision */ );
$palette = new \BrianMcdo\ImagePalette\ImagePalette( $src, 5, 3 /* number of colors to return */ );
$colors = $palette->getColors(7 /* number of colors to return */);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.