PHP code example of nikkanetiya / laravel-color-palette
1. Go to this page and download the library: Download nikkanetiya/laravel-color-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/ */
nikkanetiya / laravel-color-palette example snippets
php
// get most dominant color from image
$color = ColorPalette::getColor( 'https://rawcdn.githack.com/nikkanetiya/laravel-color-palette/master/tests/images/strawberry.jpeg' );
// Color provides several getters/properties
echo $color; // '#dc5550'
echo $color->rgbString; // 'rgb(220,85,80)'
echo $color->rgbaString; // 'rgba(220,85,80,1)'
echo $color->int; // 14439760
print_r($color->rgb); // array(220, 85, 80)
print_r($color->rgba); // array(220, 85, 80, 1)
php
// get colors from image
$colors = ColorPalette::getPalette( 'https://github.com/nikkanetiya/laravel-color-palette/blob/master/tests/images/strawberry.jpeg' );
foreach($colors as $color) {
//
}
// Colors will be array of Color Objects
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.