jacobbuck/silverstripe-dominantcolor

Enhance the Image class by providing the dominant color from an image.

1.0.0 2017-05-20 12:45 UTC

README

Enhance the Image class by providing the dominant color from an image. Uses Color Thief PHP.

Usage

Adds the DominantColor() method to Image which the primary dominant color of this Image as hex (i.e. '#bada55'.)

…
<div style="background-color:$SomeImage.DominantColor">
…

$color = Image::get()->find(…)->DominantColor();

Requirements

  • Silverstripe 3+
  • GD, Imagick or Gmagick

Installation

The recommended way to install is through Composer:

composer require jacobbuck/silverstripe-dominantcolor