Files
colorhash/tools/genexamples.sh
Alek Ratzloff 43e99e15bb Add png generation back in (using the imagemagick convert tool), add png files to gitignore
This is so we aren't committing binary data to the git repository if
that data may get updated in the future because I decide to make changes
to algorithms, palettes, etc. It's still nice to get the png files
generated so they can stay.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2024-05-30 12:26:08 -07:00

27 lines
956 B
Bash
Executable File

#!/bin/bash
set -eo pipefail
here="$(dirname "$(realpath "$0")")"
hashes=(md5 sha1 sha224 sha256 sha384 sha512)
matrices=(nibble randomart)
cd "$here/.."
find "examples" -type f -name '*.in' | \
while read infile; do
for hash in "${hashes[@]}"; do
for matrix in "${matrices[@]}"; do
svgfile="examples/$(basename -s .in "$infile")-$hash-$matrix.svg"
pngfile="examples/$(basename -s .in "$infile")-$hash-$matrix.png"
echo "Generating $svgfile"
python3 -m colorhash "$infile" --output-type svg --out "$svgfile" --hash "$hash" --matrix "$matrix"
echo "Generating $pngfile"
convert "$svgfile" "$pngfile"
done
done
done
# Additionally, create an SVG for the current commit hash
echo "Generating examples/commithash.svg"
python3 -m colorhash "$(git rev-parse HEAD)" --input-type hash --hash sha1 --matrix randomart --output-type svg --out examples/commithash.svg