Skip to content

bensquire/php-color-extractor

Repository files navigation

php-color-extractor

Build Status

The purpose of this library is to extract the main colour(s) from images. Taken from the stackoverflow answer:

(http://stackoverflow.com/questions/3468500/detect-overall-average-color-of-the-picture?answertab=active#tab-top)

Installation:

The library is PSR-0 compliant and the simplest way to install it is via composer, simply add the requirement:

"require": {
    "bensquire/php-color-extractor": "dev-master"
}

into your composer.json, then run 'composer install' or 'composer update' as required.

Example:

This example demonstrates the extraction of colors from an image file:

<?php
    include('../vendor/autoload.php');  //As needed

    use PHPColorExtractor\PHPColorExtractor;

    $extractor = new PHPColorExtractor();
    $extractor->setImage('/path/to/img.jpg')->setTotalColors(5)->setGranularity(10);
    $palette = $extractor->extractPalette();

About

A simple library to extract the palette of an image.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages