2017 © Pedro Peláez
 

library backlight

A pointless PHP library for getting the mean and glow background colors of an image or icon.

image

tyler-king/backlight

A pointless PHP library for getting the mean and glow background colors of an image or icon.

  • Sunday, December 9, 2012
  • by tyler-king
  • Repository
  • 0 Watchers
  • 3 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Backlight

Backlight is a pointless script inspired by the Ubuntu Unity Launcher. It will take an image/icon, and find it's mean background color as well as it's glow color. It will return an object with values in both RGB and HEX format for use., (*1)

Fetch

The recommended way to install Backlight is through composer., (*2)

Just create a composer.json file for your project:, (*3)

{
    "minimum-stability" : "dev",
    "require": {
        "tyler-king/backlight": "dev-master"
    }
}

And run these two commands to install it:, (*4)

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install

Now you can add the autoloader, and you will have access to the library:, (*5)

<?php
require 'vendor/autoload.php';

Usage

The usage is pretty stright forward, very chainable (see the source). This is a basic example below., (*6)

<?php

use TylerKing\Backlight\Backlight;

$backlight = new Backlight('chrome-icon.png');
print_r($backlight->getBackground()); // Returns the RGB and HEX of the background to use.
print_r($backlight->getMean()); // Returns the RGB and HEX of the outter glow to use.

By running print_r or var_dump you will receieve an output containing the mean background-color and the glow color for the icon or image., (*7)

stdClass Object
(
    [background] => stdClass Object
        (
            [rgb] => Array
                (
                    [0] => 192
                    [1] => 123
                    [2] => 18
                )

            [hex] => #c07b12
        )

    [glow] => stdClass Object
        (
            [rgb] => Array
                (
                    [0] => 229
                    [1] => 146
                    [2] => 22
                )

            [hex] => #e59216
        )

)

You can also pointlessly convert the image to pure HTML/CSS., (*8)

<?php

use TylerKing\Backlight\Backlight;

$backlight = new Backlight('chrome-icon.png');
file_put_contents('image.html', $backlight->toHTML());

By opening image.html in your browser you will now see the image in HTML/CSS format., (*9)

Notes

  • This library uses Imagick library.
  • Required PHP 5.4
  • Supported image types currently is with PNG and JPG.

The Versions

09/12 2012

dev-master

9999999-dev

A pointless PHP library for getting the mean and glow background colors of an image or icon.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Tyler King

backlight