Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
How do I format identify -list Color to show the real names and hex values in two columns? Is there a way to convert from rgb() using some IM internal?
for color in `/opt/bin/convert -list color | awk '{print $2}'`; do
hexcolor=`/opt/bin/convert xc:"$color" txt: | tail -n 1 | sed -n 's/^.*\([\#][0-9,A-F,a-f]*\) *.*$/\1/p'`;
echo $hexcolor;
done
I'm unsure of how hex colors work (will go look it up), how would I convert to 6-character hex i.e. for web?
Cheers
Edit: If you could explain how your sed statement works, that'd be awesome. I'm more used to grep & awk
the txt: outputs two lines, the second one is the color info, so tail -n 1 just grabs the last (second line).
the sed skips all characters until it finds the stuff inside \(...\) --- that is the ^.* does the skip
it then looks for # with characters 0-9 or A-F or a-f of any length and saves that --- that is \([\#][0-9,A-F,a-f]*\)
it finds and skips the next space and everything else --- that is *.*$
it returns the saved info --- that is \1
the -n says no return until told to print, which is the p at the end.
Lots of sed information by searching google for bash sed.
I am not as familiar with awk, which would be faster, but I have used it at times where speed was of the essence.
My unix may not be the most efficient, but it got the job done on my Mac OSX Snow Leopard.