PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-03-16 (11 days ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
image-color 1.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.

  Performance   Level  
Name: Arnel Labarda <contact>
Classes: 4 packages by
Country: Philippines Philippines
Innovation award
Innovation award
Nominee: 2x

Details

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  
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  /  src  
File Role Description
Files folder imageImageColor (1 file)

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

 Version Control Unique User Downloads  
 100%
Total:0
This week:0