platform_vendor_tequila/charger/regenerate.sh
Luca Stefani 3c1a396159 charger: Ensure every generated image is 8-bit
minui supports only <= 8-bit PNGs.

On my machine battery_fail was being encoded
using 24-bits and charger was freaking out :(

Change-Id: I2f63548ba102f49485c43268389f1cdd5e50802d
Signed-off-by: Luca Stefani <luca.stefani.ge1@gmail.com>
2023-01-02 20:46:48 +01:00

28 lines
905 B
Bash
Executable file

#!/bin/bash
if [ -z "$(which convert)" ] || [ -z "$(which pngcrush)" ]; then
echo "Please install imagemagick and pngcrush"
exit 1
fi
for DENSITY in mdpi:160 hdpi:240 xhdpi:320 xxhdpi:480 xxxhdpi:640; do
DPI=$(echo $DENSITY | cut -f1 -d ':')
WIDTH=$(echo $DENSITY | cut -f2 -d ':')
rm -rf $DPI
mkdir $DPI
for SVG in svg/*.svg; do
PNG="$DPI/$(basename $SVG | cut -f1 -d '.').png"
convert -density $WIDTH -resize ${WIDTH}x${WIDTH} $SVG png24:$PNG
done
SCALEFILE="$DPI/battery_scale.png"
SCALEFILES="$(ls $DPI/battery_scale_*.png)"
FRAMES="$(ls -l $SCALEFILES | wc -l)"
SCALEHEIGHT=$(($WIDTH * $FRAMES))
convert -size ${WIDTH}x${SCALEHEIGHT} canvas:black $SCALEFILES -fx "u[j%$FRAMES+1].p{i,int(j/$FRAMES)}" png24:$SCALEFILE.tmp
pngcrush -text b "Frames" "$FRAMES" $SCALEFILE.tmp $SCALEFILE
rm $SCALEFILES $SCALEFILE.tmp
done