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 (1 month ago) RSS 2.0 feedStarStarStar 52%Total: 140 This week: 59All time: 8,382 This week: 13Up
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
Nominee
Vote
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
  Performance   Level  
Name: Arnel Labarda <contact>
Classes: 4 packages by
Country: Philippines Philippines
Age: 30
All time rank: 319423 in Philippines Philippines
Week rank: 14 Up1 in Philippines Philippines Up
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 Download Rankings  
 100%
Total:140
This week:59
All time:8,382
This week:13Up
 User Ratings  
 
 All timeMonth
Utility:75%StarStarStarStar75%Equal
Consistency:75%StarStarStarStar75%Equal
Documentation:75%StarStarStarStar75%Equal
Examples:--
Tests:--
Videos:--
Overall:52%StarStarStar52%Equal
Rank:19589Up