vitorbari/image-to-color-palette

A PHP class that generates color palettes from images

1.0.2 2015-08-22 18:34 UTC

This package is auto-updated.

Last update: 2024-05-11 00:51:27 UTC


README

Build Status StyleCI

A PHP class that generates color palettes from images.

Requirements

  • GD Library

Installation

First, pull in the package through Composer.

"require": {
    "vitorbari/image-to-color-palette": "~1.0"
}

Usage

// 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);

Examples

Example 1

Result:

Array
(
    [0] => #FF00CC
    [1] => #00FF99
    [2] => #00FF66
    [3] => #00FFCC
    [4] => #99FF00
)

Example 1 result

Example 2

Result:

Array
(
    [0] => #6666CC
    [1] => #FFFFFF
    [2] => #000000
    [3] => #666699
    [4] => #666666
)

Example 2 result

Example 3

Result:

Array
(
    [0] => #0066CC
    [1] => #003366
    [2] => #CCCCCC
    [3] => #336633
    [4] => #006699
)

Example 3 result