Image-Manipulation

給定一個 .gif,將顏色分量作為 X11 樣式的十六進制說明符(或等效項)返回

  • February 16, 2012

我是 Potrace 的粉絲potrace,最近閱讀了Potrace 常見問題解答

常見問題解答包括這個漂亮的單行:

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

我正在尋找的命令將返回要解析的所有顏色的程式碼ppmcolormask。它可以返回,根據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.)
cat foo.gif | giftopnm | ppmhist -noheader -hexcolors | awk '{ print "rgb:"$1"/"$2"/"$3 }'

將為您提供 X11 rgb:r/g/b 格式的所有顏色列表。

引用自:https://unix.stackexchange.com/questions/31848