Created
February 24, 2014 17:27
-
-
Save mikkun/9192754 to your computer and use it in GitHub Desktop.
Generate Pantone/DIC/TOYO-like GIMP palette file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# generate_gpl: Generate Pantone/DIC/TOYO-like GIMP palette file | |
# | |
# Written by KUSANAGI Mitsuhisa <[email protected]> / Date: 2014-02-25 | |
tmp=/tmp/$$ | |
case "$1" in | |
Pantone) | |
url='http://www.mypantone.info/' | |
;; | |
DIC) | |
url='http://www.mydiccolor.com/' | |
;; | |
TOYO) | |
url='http://mytoyocolor.com/' | |
;; | |
*) | |
echo 'Usage: generate_gpl Pantone|DIC|TOYO' | |
exit 1 | |
;; | |
esac | |
wget -q "$url" -O $tmp-html | |
sed -e '/^<a href/!d' \ | |
-e 's/^.*#\([0-9A-Fa-f]\{6\}\).*/\1/' \ | |
-e 's/^\(..\)\(..\)\(..\)$/\1 \2 \3/' \ | |
$tmp-html > $tmp-rgb16 | |
sed -e '/^<a href/!d' \ | |
-e 's/<br>/ /g' \ | |
-e 's/^.*#[0-9A-Fa-f]\{6\}">\([^<]*\).*/\1/' \ | |
$tmp-html > $tmp-name | |
awk '{printf "%3d\n",strtonum("0x"$1)}' $tmp-rgb16 > $tmp-r10 | |
awk '{printf "%3d\n",strtonum("0x"$2)}' $tmp-rgb16 > $tmp-g10 | |
awk '{printf "%3d\n",strtonum("0x"$3)}' $tmp-rgb16 > $tmp-b10 | |
paste -d ' ' $tmp-r10 $tmp-g10 $tmp-b10 > $tmp-rgb10 | |
echo 'GIMP Palette' > "$1.gpl" | |
echo "Name: $1" >> "$1.gpl" | |
echo '#' >> "$1.gpl" | |
echo '# This file is based on the web page at' >> "$1.gpl" | |
echo "# <$url>." >> "$1.gpl" | |
echo '#' >> "$1.gpl" | |
paste $tmp-rgb10 $tmp-name >> "$1.gpl" | |
echo "File $1.gpl generated." | |
rm -f $tmp-* | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment