#!/bin/bash # # Description: Generate hex colors from a picture # Usage: sh ./color-gen image.jpg 16 # N=${2:-8} COL=$(convert "$1" -define histogram:unique-colors=true -colors $N \ -format %c histogram:info:- | sed 's/.*#/#/;' | cut -c -7 | sort -nr) OUT="" while IFS=" " read -ra ARR; do for X in "${ARR[@]}"; do OUT="$OUT$X" done done <<< "$COL" TMP="/tmp/color-generate.html" echo -e "\n" \ "\n" \ "\n" \ "Colors[$N] from \"$1\"\n" \ "\n" \ "\n" \ "\n" \ "\n" \ "

\n" \ "
\n" \ "
\n" \ "$OUT" \ "
\n" \ "

\n" \ "\n" \ "
\n" \ "

\n" \ "\n" \ "\n" > $TMP $BROWSER "$TMP" exit 0