Getting Image Colors

We were looking around for functions to get the most used colors from an image, we will be using this when we follow up our child theme creators for the twenty eleven theme, which will be released shortly.

We spent quite a while looking around the internet for some php code to find the most common colors from an image, there was code for two different libraries the Imagick and GD2, as we test with XAMPP we soon found that by default Imagick was not installed.

After a few hours we managed to find a post with decent instructions for activating Imagick on XAMPP.

We found some code and this worked quite well after some adjustments, however using this local was fine but this server and many others do not have Imagick installed.

Off we went looking for some php code so we can use the GD2 library, we found a php class file from 2002 by Andy Chase, it is hard to believe the only samples we could find were some nine years old.

In testing we found that a clone function was causing a problem so we adjusted the code and have it working, the lists of top twenty most used colors was sometimes heavy with the neutrals, so we split these, we wanted something in GD2 similar to this website which used the Imagick library.

With the help of the class written by Andy Chase we were able to get close, with the addition of an extra column for the seperated Neutrals.

We think the code needs a revival as it could help developers choose the colors for the website, we know there are web pages that do this, but it will be nice to have this as a plugin or theme feature.

We are still testing the WordPress 3.2 RC and the twenty eleven theme, we have created a website in a new folder so you can have a look at the twenty eleven theme, which has a dark and light option.

The new features are great, it has a full size editor, more post types, a featured posts page template, and a few more nice things, you can choose a dark theme, and the layout left., right or no sidebar.

We will release the colors code when WordPress 3.2 is in full release as they are still working on the theme and things may change.



We do require your feedback to improve our themes and tutorials, please leave your comments good or bad.

Code disclaimer information

If this document contains programming examples, grants you a nonexclusive copyright license to use all programming code from which you can generate similar functions tailored to your own specific needs.

All sample code is provided by for learning illustrative purposes only.

These examples have not been thoroughly tested under all conditions., therefore, cannot guarantee or imply reliability, serviceability, or function of these examples.

All programs contained herein are provided to you “AS IS” without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.


Registration and Membership is no longer required for downloading files or interacting with Digital Raindrops, posting a comment or topic in the forum does use Captcha to reduce spammers.

This website is a tool to support and promote WordPress and Artisteer theme development, please support, share and give credit for any benefits you gain from the tutorials on this website.

Leave a Reply


Connect with Us
Follow Digital Raindrops on Twitter Join Digital Raindrops on Facebook

Related Posts

Posted in Blog

Read More