| 1 |
#!/bin/sh |
| 2 |
# Matija Nalis <[email protected]>, GPLv3+ started 2020/09 |
| 3 |
# converts .png to .cpr with embedded PAL |
| 4 |
|
| 5 |
TEMPDIR=TEMP |
| 6 |
PATH="$PATH:`dirname $0`" |
| 7 |
PNGSRC="$1" |
| 8 |
FINALCPR="$2" |
| 9 |
|
| 10 |
if [ -z "$PNGSRC" -o -z "$FINALCPR" ] |
| 11 |
then |
| 12 |
echo "Usage: $0 <Graphic_Assets/SOMETHING.png> <data/SOMETHING.cpr>" |
| 13 |
echo "Converts SOMETHING.png using embedded PAL to SOMETHING.cpr with embedded PAL" |
| 14 |
exit 11 |
| 15 |
fi |
| 16 |
|
| 17 |
if [ ! -r "$PNGSRC" ] |
| 18 |
then |
| 19 |
echo "Can't read: $PNGSRC" |
| 20 |
exit 12 |
| 21 |
fi |
| 22 |
|
| 23 |
BASENAME=`basename $PNGSRC .png` |
| 24 |
|
| 25 |
TMPBASE="$TEMPDIR/$BASENAME" |
| 26 |
|
| 27 |
TMPCPR="$TMPBASE.cpr" |
| 28 |
TMPTGA="$TMPBASE.tga" |
| 29 |
|
| 30 |
echo "Converting $PNGSRC to $FINALCPR (using embedded PAL)" |
| 31 |
|
| 32 |
rm -f "$FINALCPR" |
| 33 |
convert -auto-orient "$PNGSRC" "$TMPTGA" || exit 14 |
| 34 |
tga2cpr "$TMPBASE" > /dev/null || exit 16 |
| 35 |
|
| 36 |
rm -f "$TMPTGA" |
| 37 |
mv -f "$TMPCPR" "$FINALCPR" || exit 18 |
| 38 |
exit 0 |