~scripts
58 itemsDownload ./*

58 itemsDownload ./*

..
display
dzen2
nginx
tiling
vosh
4cdl
4trips
alarm
ambient
battery-monitor
checkit
cleverbot.py
clock
color-gen
colors-hex
colorscheme.sh
compton.sh
dailywall
dmenu
ffthumb
grid
gridmacro
gridmacro.kde
help
importw
indexer
install-all.sh
install-twily.sh
installng
mp3ogg
netspeed.sh
orage
pipes
pipes.x
pipewire_bt.sh
ports
rain
randwall
readystart.sh
rotate.sh
scan.sh
screencast
screencast2
scrot
scrotw
search
skull
slocker
startblender.sh
starwars
streamit
sumnum
synctimedate.sh
tty-colorize
usrmount
ytp
ytplay
zombie-restart.sh


scriptscolor-gen
2 927•  9 years ago•  DownloadRawClose
9 years ago•  2 927

{}
#!/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<span style=\"background: $X;\" onclick=\"setbg(this);\">$X</span>"
    done
done <<< "$COL"

TMP="/tmp/color-generate.html"
echo -e "<!DOCTYPE html>\n" \
        "<html>\n" \
        "<head>\n" \
        "<title>Colors[$N] from \"$1\"</title>\n" \
        "<style type=\"text/css\">\n" \
        "html { height: 100%; }\n" \
        "body {\n" \
        "    margin: 0; padding: 0; min-height: 100%;\n" \
        "    background: #17181A; color: #000;\n" \
        "    transition: background .2s ease;\n" \
        "}\n" \
        "span {\n" \
        "    display: inline-block; width: 128px; height: 64px;\n" \
        "    text-align: center; line-height: 64px;\n" \
        "}\n" \
        "div,img { max-width: calc(128px * 8); }\n" \
        "</style>\n" \
        "<script type=\"text/javascript\">\n" \
        "function setbg(x) { document.body.style.background=x?x.style.background:x; }\n" \
        "</script>\n" \
        "</head>\n" \
        "<body>\n" \
        "<br /><br />\n" \
        "<center>\n" \
        "<div>\n" \
        "$OUT" \
        "</div>\n" \
        "<br /><br />\n" \
        "<img src=\"file://$(pwd)/$1\" onclick=\"setbg('');\" />\n" \
        "</center>\n" \
        "<br /><br />\n" \
        "</body>\n" \
        "</html>\n" > $TMP

$BROWSER "$TMP"

exit 0

Top
©twily.info 2013 - 2024
twily at twily dot info



2 158 813 visits
... ^ v