Skip to content

Generating Color Palette Using ColdFusion & ImageMagick

twitter logo ・1 min read  

I read Ben Nadel's recent ColdFusion post on Exploring Color Histograms In GraphicsMagick And Lucee CFML and thought I'd compare it with ImageMagick.

ImageMagick returns a list of color data in a low-to-high order. I used ReMatch to identify the hex colors via regex, generated an array and then reversed it.

NOTE: I wanted to compare performance using Ben's script, but his "Lucee CFML" script wasn't written to be compatible with ColdFusion 2016. :(


colors = extractPalette(imagePath, numberOfColors);

Source Code

twitter logo DISCUSS (1)
markdown guide

I came across some similar things in various ImageMagick forums when I was looking into this. I wonder if the -define histogram:unique-colors=true is part of why I am not getting results that I love. GraphicsMagick doesn't seem to have an equivalent setting.

On various color palette posts, I did see that some people were calculating the "distance" between colors to help figure out a palette. But, I am not so good at maths ... or understanding color theory :D Part of me is like, let me just show the top 30 colors and let the user pick out whatever they like.

Classic DEV Post from Feb 12

Five Myths of Salary Negotiation

In this video I debunk five negotiation myths that I've seen personally and from talking with candida...

James Moberg profile image
I’m a ColdFusion web application developer at SunStar Media located in Monterey, CA. I am a fan of technology, music and web development.