File: quantize_pixmaps

package info (click to toggle)
fvwm 1%3A2.5.18-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 13,084 kB
  • ctags: 14,319
  • sloc: ansic: 160,604; perl: 10,958; sh: 9,922; makefile: 1,109; yacc: 683; lex: 169; sed: 11
file content (50 lines) | stat: -rwxr-xr-x 1,219 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
cd $HOME/tmp-icons

# We process all of the xpm files in ~/icons, reducing their collective
# colourmap, and producing files in ~/tmp-icons.

# Make a note of those files with transparent bits for zapping afterwards:
# this isn't perfect, but seems to work OK for the pixmaps that I use.

# Notice that the input, output, and number of colours are hardwired.

# (The ppmtogif | giftoppm is to make sure the ppm file is in raw format, because
# ppmquant appears not to work with the result of xpmtoppm!)

echo Converting files to ppm format
NONE=""
for i in ../icons/*.xpm
do
    echo -n $i " "
    sed 's/[Nn]one/black/g' $i | xpmtoppm | ppmtogif | giftoppm > `basename $i .xpm`.ppm
    if test -s `basename $i .xpm`.ppm
    then
	if grep -iq None $i
	then
	    NONE="$NONE `basename $i`"
	fi
    else
        rm -f `basename $i .xpm`.ppm
    fi
done

echo Performing quantization to 32 colours
ppmquantall 32 *.ppm

echo Converting to xpm format again
for i in *.ppm
do
    echo -n $i " "
    ppmtoxpm $i > `basename $i .ppm`.xpm
    rm -f $i
done

echo Trying to fix transparent pixels in some files
for i in $NONE
do
    echo $i
    sed 's/` c #000000/` c None/' $i > $i-tmp.xpm
    mv $i-tmp.xpm $i
done