2020-05-07 06:57:51 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-10-20 14:07:08 +00:00
|
|
|
echo "var mappingArray = [" > mapping.js
|
2020-10-19 21:43:10 +00:00
|
|
|
echo "var bitmapSizeMapping = {" > bitmap-map.js
|
2020-05-07 06:57:51 +00:00
|
|
|
|
2020-10-20 14:07:08 +00:00
|
|
|
shopt -s globstar
|
|
|
|
for file in **/*; do
|
2020-05-07 06:57:51 +00:00
|
|
|
|
|
|
|
filename="${file%.*}"
|
|
|
|
fl="$(echo "$filename" | tr '[:upper:]' '[:lower:]')"
|
2020-10-18 19:22:59 +00:00
|
|
|
|
2020-10-20 06:25:29 +00:00
|
|
|
if [ -f "${file}" ]
|
2020-10-18 19:22:59 +00:00
|
|
|
then
|
|
|
|
md5=`md5sum "${file}" | awk '{ print $1 }'`
|
2020-05-07 06:57:51 +00:00
|
|
|
|
2020-10-19 21:43:10 +00:00
|
|
|
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
|
2020-10-20 06:25:29 +00:00
|
|
|
else
|
|
|
|
md5=''
|
2020-10-19 21:43:10 +00:00
|
|
|
fi
|
|
|
|
|
2020-10-20 14:07:08 +00:00
|
|
|
echo "[\"$fl\", \"${file}?h=${md5}\"]," >> mapping.js
|
2020-10-20 06:25:29 +00:00
|
|
|
|
2020-05-07 06:57:51 +00:00
|
|
|
done
|
|
|
|
|
2020-10-20 14:07:08 +00:00
|
|
|
echo "];" >> mapping.js
|
2020-10-19 21:43:10 +00:00
|
|
|
echo "};" >> bitmap-map.js
|
2020-05-07 06:57:51 +00:00
|
|
|
|
2020-10-20 14:07:08 +00:00
|
|
|
echo "
|
|
|
|
var mapping = {};
|
|
|
|
for (var i = 0; i < mappingArray.length; i++) {
|
|
|
|
mapping[mappingArray[i][0]] = mappingArray[i][1];
|
|
|
|
}
|
|
|
|
" >> mapping.js
|
|
|
|
|