Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a fan of potrace, and I recently read the Potrace FAQ.

The FAQ includes this beautiful one-liner:

cat img.gif | giftopnm | ppmcolormask #641b1b | potrace

The command I am looking for would return the codes of all the colors to be parsed by ppmcolormask. It could return, according to man ppmcolormask:

   You can specify color five ways:

   o      An X11-style color name (e.g.  black).

   o      An  X11-style  hexadecimal specifier: rgb:r/g/b, where r g and b
          are each 1- to 4-digit hexadecimal numbers.

   o      An X11-style decimal specifier: rgbi:r/g/b, where r g and b  are
          floating point numbers between 0 and 1.

   o      For  backwards  compatibility, an old-X11-style hexadecimal num‐
          ber: #rgb, #rrggbb, #rrrgggbbb, or #rrrrggggbbbb.

   o      For backwards compatibility, a triplet of numbers  separated  by
          commas:  r,g,b,  where  r  g  and  b  are floating point numbers
          between 0 and 1.  (This style was added before MIT came up  with
          the similar rgbi style.)
share|improve this question
up vote 2 down vote accepted
cat foo.gif | giftopnm | ppmhist -noheader -hexcolors | awk '{ print "rgb:"$1"/"$2"/"$3 }'

will give you a list of all the colors in X11 rgb:r/g/b format.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.