A PHP class that generates color palettes from images.
- GD Library
First, pull in the package through Composer.
"require": {
"vitorbari/image-to-color-palette": "~1.0"
}
// Create new ColorPalette object
$palette = new VitorBari\ImageToColorPalette\ColorPalette();
// Set image
$palette->set_image_file('images/myimg.jpg');
// Get colors
$colors = $palette->get_palette();
// Print colors
echo "<pre>";
print_r($colors);
Result:
Array
(
[0] => #FF00CC
[1] => #00FF99
[2] => #00FF66
[3] => #00FFCC
[4] => #99FF00
)
Result:
Array
(
[0] => #6666CC
[1] => #FFFFFF
[2] => #000000
[3] => #666699
[4] => #666666
)
Result:
Array
(
[0] => #0066CC
[1] => #003366
[2] => #CCCCCC
[3] => #336633
[4] => #006699
)