PHP Classes

PHP Dominant Color: Create image with color of another dominant color

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 52%Total: 177 All time: 8,749 This week: 206Up
Version License PHP version Categories
image-color 1.0.0MIT/X Consortium ...5PHP 5, Graphics
Description 

Author

This class can create an image with color of another image dominant color.

It can take a given image and resizes it to a small size using ImageMagick extension to apply a gaussian filter during resizing and then use the quantize filter to reduce the colors and find out the dominant color.

The class can generate a new image using the dominant color and returns it as a data URL string for a GIF image with one pixel of that color.

Innovation Award
PHP Programming Innovation award nominee
March 2017
Number 2


Prize: One big elePHPant Plush Mascott
Some applications need to display an image in a background that matches the most common color of the image.

This package can find the dominant color of an image and creates a new image in the GIF format with one pixel using that dominant color.

Manuel Lemos
Picture of Arnel Labarda
  Performance   Level  
Name: Arnel Labarda <contact>
Classes: 6 packages by
Country: Philippines Philippines
Age: 37
All time rank: 247922 in Philippines Philippines
Week rank: 214 Up2 in Philippines Philippines Up
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

Documentation

ImageColor

Creates a data-uri based on the image dominant color.

Requirements

ImageMagick extension should be present.

Usage

require './vendor/autoload.php';

$image_url = 'https://www.elephantnaturepark.org/wp-content/uploads/2016/06/Lek_20may2016_01_n.jpg';

$i = new ImageColor\ImageColor($image_url);

echo $i->get_data_uri();

Credits

  • https://manu.ninja/dominant-colors-for-lazy-loading-images
  • https://www.webrocker.de/2016/03/28/dominant-color-in-an-image/

  Files folder image Files (3)  
File Role Description
Files folder imagesrc (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (3)  /  src  
File Role Description
Files folder imageImageColor (1 file)

  Files folder image Files (3)  /  src  /  ImageColor  
File Role Description
  Plain text file ImageColor.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:177
This week:0
All time:8,749
This week:206Up
 User Ratings  
 
 All time
Utility:75%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:75%StarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:52%StarStarStar
Rank:2406