#!/bin/bash
#------------------------------------------------------------
# To get file back from image
#
# $ ./fromcolor.sh imagefilename.png > restoredfile.name
#
# You will be prompted for your encryption key/passphrase
#------------------------------------------------------------
fabcounter=0
declare -A fabcolors
alphaarray=(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
# Blues and purples theme
colorarray=(000080 00008B 0000CD 0000FF 191970 1E90FF 4169E1 483D8B 4B0081 4B0182 6A5ACD 7B68EE 800080 8A2BE1 8A2CE2 8B008B 9370DB 9400D3 9932CC BA55D3 D8BFD8 DA70D6 DDA0DD E6E6FA EE82EE FF11FF FF00FF)
# Or dark greys to look black instead
# colorarray=(000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 000013 000014 000015 000016 000017 000018 000019 000020 000021 000022 000023 000024 000025 000026)
for onecolor in "${colorarray[@]}"
do
fabcolors["$onecolor"]="${alphaarray[$fabcounter]}"
let fabcounter+=1
done
# while loop
convert "$1" txt: | cut -f 2 -d'#' |cut -f 1 -d' ' | (
while IFS= read c
do
let counter+=1
if [[ " ${colorarray[@]} " =~ " ${c} " ]]; then
color=${fabcolors[$c]}
if [ $color ]; then
echo -n $color
fi
fi
done
) | tr '.' " " | sed 's/.\{5\}/& /g' |codegroup -d |ccrypt -d
Comments