mirror of
https://github.com/ivuorinen/palette.git
synced 2026-01-26 11:34:09 +00:00
1.0.1
- Added vendor folder
composer.json:
- Added required description
- Fixed autoloader classmap
- Removed extra-section
example.php:
- Now has working autoloader and non-autoloader examples
- Better wording in comments and caching example, also includes destination configuration example
Palette.php:
- Added MIT license block and changed the license links from GPL2 to MIT to reflect composer.json file
- Moved file from from a directory to a better one, reflecting class namespace.
- Combined tests to fewer try {} catch {} -blocks
- Added comments to help understand the code
Palette
Palette is a PHP class that takes your images and returns used colors, sorts them by usage and saves the results.
Usage
After adding Palette to your composer.json file and installed to your vendor folder, you can use the class like this:
With default settings
$image = "example/example.jpg";
$palette = new \ivuorinen\Palette\Palette($image);
print_r($palette->colorsArray);
With custom settings
$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);
Languages
PHP
100%