]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/generate-dds.sh
JPEG and DDS generator scripts (untested)
[xonotic/xonotic.git] / misc / tools / generate-dds.sh
1 #!/bin/sh
2
3 set -e
4
5 for X in "$@"; do
6         case "$X" in
7                 *.jpg)
8                         if [ -n "$scaledown" ]; then
9                                 mogrify -geometry "$scaledown" -quality 100 "$X"
10                         fi
11                         echo "$X has no alpha, converting"
12                         nvcompress -bc1 "$X" "${X%.*}.dds"
13                         rm -f "$X"
14                         ;;
15                 *.png|*.tga)
16                         if [ -n "$scaledown" ]; then
17                                 mogrify -geometry "$scaledown" -quality 100 "$X"
18                         fi
19                         if convert "$X" -depth 16 RGBA:- | perl -e 'while(read STDIN, $_, 8) { substr($_, 6, 2) eq "\xFF\xFF" or exit 1; ++$pix; } exit not $pix;'; then
20                                 echo "$X has no alpha, converting"
21                                 nvcompress -bc1 "$X" "${X%.*}.dds"
22                                 rm -f "$X"
23                         else
24                                 echo "$X has alpha, converting"
25                                 nvcompress -alpha -bc3 "$X" "${X%.*}.dds"
26                                 rm -f "$X"
27                         fi
28                         ;;
29         esac
30 done