Skip to content

Commit d4c08df

Browse files
committed
Add the script to convert pieces as reference
1 parent 80b69eb commit d4c08df

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

scripts/convert_svgs_to_pngs.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# This script converts all SVGs in the lila/public/piece folder to PNGs in the output folder using Inkscape.
4+
# Script taken from @tiagoamaro's PR: https://github.com/lichess-org/flutter-chessground/pull/28
5+
6+
SOURCE_DIR="./lila/public/piece"
7+
DEST_DIR="./output"
8+
SCALING_FACTORS=("1 ." "2 ./2.0x" "3 ./3.0x" "4 ./4.0x")
9+
10+
for dname in $(ls -d $SOURCE_DIR/*); do
11+
if [ -d "$dname" ]; then
12+
for factor_folder in "${SCALING_FACTORS[@]}"; do
13+
read -r -a factor_folder_array <<< "$factor_folder"
14+
factor=${factor_folder_array[0]}
15+
folder=${factor_folder_array[1]}
16+
for fname in $(ls $dname); do
17+
fpath="$dname/$fname"
18+
if [ -f "$fpath" ]; then
19+
out_folder="$DEST_DIR/${dname##*/}/$folder"
20+
echo $out_folder
21+
mkdir -p $out_folder
22+
fname_without_extension="${fname%.*}"
23+
png="$out_folder/$fname_without_extension.png"
24+
echo "Converting $fpath to $png"
25+
size=$((128 * factor))
26+
inkscape --export-type="png" --export-width="$size" --export-height="$size" --export-filename="$png" $fpath &
27+
fi
28+
done
29+
done
30+
fi
31+
done

0 commit comments

Comments
 (0)