mkxp/extra/make_mapping.sh

40 lines
798 B
Bash
Raw Normal View History

2020-05-07 06:57:51 +00:00
#!/bin/bash
echo "var mapping = {" > mapping.js
2020-10-19 21:43:10 +00:00
echo "var bitmapSizeMapping = {" > bitmap-map.js
2020-05-07 06:57:51 +00:00
for file in {*,*/*,*/**/*}
do
filename="${file%.*}"
fl="$(echo "$filename" | tr '[:upper:]' '[:lower:]')"
2020-10-18 19:22:59 +00:00
if [ -f $file ]
then
md5=`md5sum "${file}" | awk '{ print $1 }'`
else
md5=''
fi
2020-05-07 06:57:51 +00:00
echo "\"$fl\": \"${file}?h=${md5}\"," >> mapping.js
2020-10-19 21:43:10 +00:00
if [ -f $file ]
then
sz=`identify -format "%w,%h" "${file}" 2>/dev/null`
if [ $? -eq 0 ]; then
2020-10-20 00:18:27 +00:00
convert "$file" -resize 64x64\> "conv.png"
mimetype=$(file -bN --mime-type "conv.png")
content=$(base64 -w0 < "conv.png")
duri="data:$mimetype;base64,$content"
rm "conv.png"
echo "\"$fl\": [${sz},\"${duri}\"]," >> bitmap-map.js
2020-10-19 21:43:10 +00:00
fi
fi
2020-05-07 06:57:51 +00:00
done
echo "};" >> mapping.js
2020-10-19 21:43:10 +00:00
echo "};" >> bitmap-map.js
2020-05-07 06:57:51 +00:00