Important facts about commercial licenses

  • Licenses are perpetual. They do not expire and do not need to be renewed.
  • Licenses can be upgraded. You can upgrade to a more expensive license later paying only the difference in cost.
  • Pay attention to the distribution type - Hosted (sites / servers), binary (applications) or source (includes all the others). Choose according to your needs (more below).
  • All licenses allow commercial use unless otherwise indicated.
  • Read the full license by clicking on the icon.
  • Read more about licenses in our handy license guide.
$4

Personal License

1 site, unlimited servers No source distribution
$40

Developer License

Unlimited projects Source and binary distribution
You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

Image color detection and extraction

Image color detection and extraction
Developed by Gerson Alexander, Released May 19, 2011

This PHP Image color detection class lets you easily extract the dominant colors from an image and apply a watermark

PHP

Tags: color , color detection , fast , image

This PHP color detection & image watermarking class can easily obtain an array of colors dominant in an image in RGB and HEXA formats using simple PHP syntax.

It supports GIF, JPG and PNG.

Example:

include_once 'config.inc.php'; 
include_once 'class/colorExtractor.class.php';
$colorExtractor = new ColorExtractor();
$colors = $colorExtractor->getColors($image);
print_r($colors);

Example output:

  Array
(
 [0] => Array
    (
        [RGB] => 10-103-23
        [HEXA] => 0A6717
    )

[1] => Array
    (
        [RGB] => 10-84-21
        [HEXA] => 0A5415
    )

[2] => Array
    (
        [RGB] => 2-87-48
        [HEXA] => 025730
    )

[3] => Array
    (
        [RGB] => 21-136-15
        [HEXA] => 15880F
    )

[4] => Array
    (
        [RGB] => 4-75-9
        [HEXA] => 044B09
    )

[5] => Array
    (
        [RGB] => 5-60-39
        [HEXA] => 053C27
    )
)

Example Watermark:

  // image.php file
   header('Content-Type: image/png');
   include_once 'config.inc.php'; 
   include_once 'class/colorExtractor.class.php';
   $colorExtractor= new ColorExtractor();

  $image = $_GET['image'];
  $colorRGB = $_GET['colorRGB'];
  $colorExtractor->rgb_alpha=1; // for PNG transparent
  $colorExtractor->img_watermark='default/mark.png';  //watermark
  $colorExtractor->ImageFusion($image,$colorRGB);

See the screenshots for examples of images and their dominant colors output.

User Reviews

No reviews have been submitted yet.
Read all 1 comments »

Questions & Comments


Or enter your name and Email
  • Peter Drinnan 6 months ago
    This would be really useful for checking WCAG color contrast.
You must be logged-in to vote. Log-in to your account or register now.