umneeq/yii2-color-extractor

Extract colors from an image like a human would do

Installs: 212

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 1

Forks: 2

Open Issues: 0

Type:yii2-extension

dev-master 2015-11-06 10:55 UTC

This package is not auto-updated.

Last update: 2024-03-20 15:46:04 UTC


README

Extract colors from an image like a human would do. Based on thephpleague/color-extractor

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist umneeq/yii2-color-extractor "*"

or add

"umneeq/yii2-color-extractor": "*"

to the require section of your composer.json file and run composer update command.

Usage

Notification. This extension accept 3 types of images: jpeg(jpg), png, gif

Once the extension is installed, simply use it in your code by:

use \umneeq\colorextractor\ColorExtractor;

$imagePath = \Yii::getAlias('@frontend/web/img') . DIRECTORY_SEPARATOR . 'test.png';

// Get four most used color hex code
$result = ColorExtractor::extract($imagePath, 4);

// $result
[
    0 => '#F76C0F',
    1 => '#F0C67F',
    2 => '#AABBCC',
    3 => '#CCBBAA',
]