don't update min/max bounding box when drawing with CLEAR polarity
[geda-gerbv.git] / desktop / regen_files
blob67571b034775ff163c46f3956fe5ec611300d7c0
1 #!/bin/sh
3 # $Id$
6 CONVERT=${CONVERT:-convert}
7 COMPOSITE=${COMPOSITE:-composite}
8 INKSCAPE=${INKSCAPE:-inkscape}
9 PPMTOWINICON=${PPMTOWINICON:-ppmtowinicon}
11 do_inkscape=yes
12 do_convert=yes
13 do_winicon=yes
15 usage() {
16 cat << EOF
18 $0 -- Regenerate desktop icon files and windows icon files
20 Options
22 --help Displays this message and exits
24 --skip-png Skips the regeneration of the .png file(s)
26 --skip-winicon Skips the regneration of the Windows icon file(s)
28 EOF
32 while test $# -ne 0 ; do
33 case $1 in
34 --help)
35 usage
36 exit 0
39 --skip-png)
40 do_inkscape=no
41 shift
44 --skip-winicon)
45 do_convert=no
46 do_winicon=no
47 shift
50 -*)
51 echo "$0: Unknown option $1"
52 usage
53 exit 1
57 break
59 esac
60 done
62 if test $? -ne 0 ; then
63 usage
64 exit 1
68 ## Export the SVG graphics
71 # see if we have inkscape
72 if test $do_inkscape = yes ; then
73 ${INKSCAPE} --version 2>&1 >/dev/null
74 if test $? -ne 0 ; then
75 echo "\"${INKSCAPE} --version\" failed."
76 echo "Make sure that inkscape is installed and functional on your system."
77 echo "Skipping the SVG -> PNG conversion."
78 do_inkscape=no
82 if test $do_inkscape = yes ; then
83 echo "Export SVG graphics to png..."
85 for r in 16 22 24 32 48 ; do
86 case ${r} in
87 24)
88 x=-1
89 y=23
90 rs=22
93 x=0
94 y=${r}
95 rs=${r}
97 esac
98 for f in *-${rs}.svg ; do
99 fb=`basename ${f} ${rs}.svg`
100 p="${fb}${r}.png"
101 echo "${f} -> ${p}"
102 ${INKSCAPE} --export-png=${p} --export-area=${x}:${x}:${y}:${y} ${f}
103 done
104 done
108 ## Generate the windows icon file
111 app_icon="gerbv"
113 if test $do_convert = yes ; then
114 # see if we have ImageMagick
115 ${CONVERT} --version 2>&1 >/dev/null
116 if test $? -ne 0 ; then
117 echo "\"${CONVERT} --version\" failed."
118 echo "Make sure that ImageMagick is installed and functional on your system."
119 echo "Skipping the PNG -> PPM conversion."
120 do_convert=no
124 if test $do_convert = yes ; then
125 echo "Creating windows pbm mask files..."
126 ${CONVERT} -channel matte -separate +matte ${app_icon}-48.png - |
127 ${CONVERT} -threshold 65534 -negate - 48_mask.pbm
128 ${CONVERT} -channel matte -separate +matte ${app_icon}-32.png - |
129 ${CONVERT} -threshold 65534 -negate - 32_mask.pbm
130 ${CONVERT} -channel matte -separate +matte ${app_icon}-16.png - |
131 ${CONVERT} -threshold 65534 -negate - 16_mask.pbm
133 echo "Creating windows ppm flattened files..."
134 ${CONVERT} -flatten -colors 16 ${app_icon}-48.png 48_16.ppm
135 ${CONVERT} -flatten -colors 256 ${app_icon}-48.png 48_256.ppm
136 ${CONVERT} -flatten -colors 16 ${app_icon}-32.png 32_16.ppm
137 ${CONVERT} -flatten -colors 256 ${app_icon}-32.png 32_256.ppm
138 ${CONVERT} -flatten -colors 16 ${app_icon}-16.png 16_16.ppm
139 ${CONVERT} -flatten -colors 256 ${app_icon}-16.png 16_256.ppm
142 # see if we have netpbm
143 if test $do_winicon = yes ; then
144 ${PPMTOWINICON} --version 2>&1 >/dev/null
145 if test $? -ne 0 ; then
146 echo "\"${PPMTOWINICON} --version\" failed."
147 echo "Make sure that netpbm is installed and functional on your system."
148 echo "Skipping the pbm -> windows icon conversion."
149 do_winicon=no
153 if test $do_winicon = yes ; then
154 echo "Creating windows icon file..."
155 ${PPMTOWINICON} -output gerbv_icon.ico -andpgms\
156 48_16.ppm 48_mask.pbm 48_256.ppm 48_mask.pbm\
157 32_16.ppm 32_mask.pbm 32_256.ppm 32_mask.pbm\
158 16_16.ppm 16_mask.pbm 16_256.ppm 16_mask.pbm
161 rm -f \
162 48_16.ppm 48_256.ppm 48_mask.pbm\
163 32_16.ppm 32_256.ppm 32_mask.pbm\
164 16_16.ppm 16_256.ppm 16_mask.pbm
166 echo "All done"