paletterx 574 B

123456789101112131415161718
  1. #!/bin/bash
  2. # takes an image and creates a color palette from it
  3. # depends: imagemagick
  4. PALETTE=$(convert "$1" -colors 16 -format "%c" histogram:info:)
  5. HEXLIST=$(echo "$PALETTE" | sed 's/^.*\#\(.*\) srgb.*/\1/g')
  6. COL=("0" "8" "1" "9" "2" "A" "3" "B" "4" "C" "5" "D" "6" "E" "7" "F");
  7. CLEAN=$(echo $COL | sed 's/^0*//')
  8. x=0
  9. ## Get the ouput of the color palette
  10. while read -r line; do
  11. [[ "$line" ]] || continue
  12. echo -en *color$x: '#'"${CLEAN}$line\n";
  13. x=$((x+1))
  14. done < <(convert "$1" -colors 16 -format "%c" histogram:info: | sed 's/^.*\#\(.*\) srgb.*/\1/g')