Skip to content

Instantly share code, notes, and snippets.

@hayesr
Last active July 15, 2017 18:47
Show Gist options
  • Save hayesr/9f2fad55b529937ecf857dbd9dbb6a39 to your computer and use it in GitHub Desktop.
Save hayesr/9f2fad55b529937ecf857dbd9dbb6a39 to your computer and use it in GitHub Desktop.
Extract colors from an image using ImageMagick

Get colors from a photo using ImageMagick

Command

Using image: https://unsplash.com/new?photo=5RydGpXvpxE by Thomas Bühler

convert thomas-buhler-301493.jpg -colors 16 -depth 8 -format '%c' histogram:info:- \
| sort --reverse --numeric-sort

Output

2580689: (174,175,188) #AEAFBC srgb(174,175,188)
2552855: (156,172,195) #9CACC3 srgb(156,172,195)
2532178: (181,193,206) #B5C1CE srgb(181,193,206)
2498111: (  2, 22, 54) #021636 srgb(2,22,54)
2103417: (171,183,198) #ABB7C6 srgb(171,183,198)
1152417: (149,149,175) #9595AF srgb(149,149,175)
 944167: ( 94,112,153) #5E7099 srgb(94,112,153)
 929520: (120,133,171) #7885AB srgb(120,133,171)
 864409: (211,198,200) #D3C6C8 srgb(211,198,200)
 816953: (210,179,180) #D2B3B4 srgb(210,179,180)
 740881: ( 49, 86,139) #31568B srgb(49,86,139)
 545659: (156,109,120) #9C6D78 srgb(156,109,120)
 520687: ( 68, 74,112) #444A70 srgb(68,74,112)
 458231: ( 24, 46, 90) #182E5A srgb(24,46,90)
 429733: ( 31, 34, 60) #1F223C srgb(31,34,60)
 291949: (120,146,195) #7892C3 srgb(120,146,195)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment