PHP code example of ivuorinen / palette
1. Go to this page and download the library: Download ivuorinen/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/ */
ivuorinen / palette example snippets
$image = "example/example.jpg";
$palette = new \ivuorinen\Palette\Palette($image);
print_r($palette->colorsArray);
$palette = new \ivuorinen\Palette\Palette();
$palette->filename = "example/example.jpg"; // Our image
$palette->precision = 10; // Precision of color collection
$palette->returnColors = 10; // How many colors we want
$palette->destination = './data/' . md5($palette->filename) . '.json';
// Do the work (same as ``Palette::run()``)
$this->getPalette();
$this->save(); // Not needed, but caching results <3
// We now have ``./data/7233c3b944f5299c6983c77c94e75dce.json`` (if everything went smoothly)
// and we can test against it before running palette generation. Which you should do really.
print_r($palette->colorsArray);