fvwm-convert-2.6: Handle "+ foo" lines correctly by not culling them.
[fvwm.git] / utils / quantize_pixmaps
blob218b53c5d9adcef2a0dbb65b9d8c8e926e6c05f1
1 #!/bin/sh
2 cd $HOME/tmp-icons
4 # We process all of the xpm files in ~/icons, reducing their collective
5 # colourmap, and producing files in ~/tmp-icons.
7 # Make a note of those files with transparent bits for zapping afterwards:
8 # this isn't perfect, but seems to work OK for the pixmaps that I use.
10 # Notice that the input, output, and number of colours are hardwired.
12 # (The ppmtogif | giftoppm is to make sure the ppm file is in raw format, because
13 # ppmquant appears not to work with the result of xpmtoppm!)
15 echo Converting files to ppm format
16 NONE=""
17 for i in ../icons/*.xpm
19 echo -n $i " "
20 sed 's/[Nn]one/black/g' $i | xpmtoppm | ppmtogif | giftoppm > `basename $i .xpm`.ppm
21 if test -s `basename $i .xpm`.ppm
22 then
23 if grep -iq None $i
24 then
25 NONE="$NONE `basename $i`"
27 else
28 rm -f `basename $i .xpm`.ppm
30 done
32 echo Performing quantization to 32 colours
33 ppmquantall 32 *.ppm
35 echo Converting to xpm format again
36 for i in *.ppm
38 echo -n $i " "
39 ppmtoxpm $i > `basename $i .ppm`.xpm
40 rm -f $i
41 done
43 echo Trying to fix transparent pixels in some files
44 for i in $NONE
46 echo $i
47 sed 's/` c #000000/` c None/' $i > $i-tmp.xpm
48 mv $i-tmp.xpm $i
49 done